Skip to content

Commit 9aa75c1

Browse files
committed
Merge branch 'release-rnp'
2 parents c5b684e + a57aa3f commit 9aa75c1

5 files changed

Lines changed: 64 additions & 9 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ features/config.yml
55
logs/bbb.log
66
rdoc/
77
logs/*
8-
.bundle/
8+
.bundle/
9+
.volumes/

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM ruby:2.3.8
2+
3+
ENV app /usr/src/app
4+
5+
# Create app directory
6+
RUN mkdir -p $app
7+
WORKDIR $app
8+
9+
# Bundle app source
10+
COPY . $app
11+
12+
# Install app dependencies
13+
RUN bundle install

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: '2'
2+
services:
3+
4+
test:
5+
build: .
6+
tty: true
7+
volumes:
8+
- $PWD:/usr/src/app
9+
- .volumes/bundle/:/usr/local/bundle
10+
command: bundle exec rake

lib/bigbluebutton_formatter.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ def to_datetime(key)
4949
if value.is_a?(Numeric)
5050
result = value == 0 ? nil : DateTime.parse(Time.at(value/1000.0).to_s)
5151
else
52-
if value.downcase == "null"
52+
if (value.is_a?(Hash) || value.is_a?(Array)) && value.empty?
53+
result = nil
54+
elsif value.is_a?(String) && (value.empty? || value.downcase == 'null')
5355
result = nil
5456
else
5557
# note: just in case the value comes as a string in the format: "Thu Sep 01 17:51:42 UTC 2011"

spec/bigbluebutton_formatter_spec.rb

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,43 @@
100100
it { hash[:param7].should == nil }
101101
it { hash[:param8].should == nil }
102102

103-
context "returns nil if the param doesn't exists" do
104-
subject { BigBlueButton::BigBlueButtonFormatter.new({ :param => 1}) }
105-
it { subject.to_datetime(:inexistent).should == nil }
106-
end
103+
context "returns nil if" do
104+
context "the param doesn't exists" do
105+
subject { BigBlueButton::BigBlueButtonFormatter.new({ :param => 1}) }
106+
it { subject.to_datetime(:inexistent).should == nil }
107+
end
107108

108-
context "returns nil if the hash is nil" do
109-
subject { BigBlueButton::BigBlueButtonFormatter.new(nil) }
110-
it { subject.to_datetime(:inexistent).should == nil }
109+
context "the hash is nil" do
110+
subject { BigBlueButton::BigBlueButtonFormatter.new(nil) }
111+
it { subject.to_datetime(:inexistent).should == nil }
112+
end
113+
114+
context "the value is an empty string" do
115+
subject { BigBlueButton::BigBlueButtonFormatter.new({ param1: '' }) }
116+
it { subject.to_datetime(:param1).should == nil }
117+
end
118+
119+
context "the value is nil" do
120+
subject { BigBlueButton::BigBlueButtonFormatter.new({ param1: nil }) }
121+
it { subject.to_datetime(:param1).should == nil }
122+
end
123+
124+
context "the value is an empty hash" do
125+
subject { BigBlueButton::BigBlueButtonFormatter.new({ param1: {} }) }
126+
it { subject.to_datetime(:param1).should == nil }
127+
end
128+
129+
context "the value is an empty array" do
130+
subject { BigBlueButton::BigBlueButtonFormatter.new({ param1: [] }) }
131+
it { subject.to_datetime(:param1).should == nil }
132+
end
133+
134+
['null', 'NULL'].each do |v|
135+
context "the value is '#{v}'" do
136+
subject { BigBlueButton::BigBlueButtonFormatter.new({ param1: v }) }
137+
it { subject.to_datetime(:param1).should == nil }
138+
end
139+
end
111140
end
112141
end
113142

0 commit comments

Comments
 (0)