Skip to content

Commit 4c8200e

Browse files
Bernardo AndersonBernardo Anderson
andauthored
MWEB-2568 - Update check for empty string (#165)
* MWEB-2568 - Update check for empty string Date will be coming as empty string instead of nil for Virtual Open House and Virtual Tour of Home. * MWEB-2568 - Add changelog/version and empty check against other fields * MWEB-2568 - Fix mistakes and add tests Co-authored-by: Bernardo Anderson <banderson@fbsdata.com>
1 parent f8b16cd commit 4c8200e

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
v1.4.32
2+
- Updated check on Open Houses and Tour of Homes for empty string
3+
14
v1.4.31
25
- Updated requests to allow arrays as a body
36

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.31
1+
1.4.32

lib/spark_api/models/subresource.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ def find_by_id(id, parent_id, arguments={})
1616

1717
def parse_date_start_and_end_times(attributes)
1818
# Transform the date strings
19-
unless attributes['Date'].nil?
19+
unless attributes['Date'].nil? || attributes['Date'].empty?
2020
date = Date.strptime attributes['Date'], '%m/%d/%Y'
2121
['StartTime','EndTime'].each do |time|
22-
next if attributes[time].nil?
22+
next if attributes[time].nil? || attributes[time].empty?
2323
formatted_date = "#{attributes['Date']}T#{attributes[time]}"
2424
datetime = nil
2525

spec/unit/spark_api/models/subresource_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,22 @@
7171

7272
expect {dummy_class.parse_date_start_and_end_times(times)}.to raise_error(ArgumentError)
7373
end
74+
75+
it "should ignore an empty Date" do
76+
times = {'Date' => '', 'StartTime' => '09:12:34-0700', 'EndTime' => '12:43:21-0700'}
77+
dummy_class.parse_date_start_and_end_times(times)
78+
times['Date'].should eq('')
79+
end
80+
81+
it "should ignore an empty StartTime" do
82+
times = {'Date' => '10/01/2012', 'StartTime' => '', 'EndTime' => '12:43:21-0700'}
83+
dummy_class.parse_date_start_and_end_times(times)
84+
times['StartTime'].should eq('')
85+
end
86+
87+
it "should ignore an empty EndTime" do
88+
times = {'Date' => '10/01/2012', 'StartTime' => '09:12:34-0700', 'EndTime' => ''}
89+
dummy_class.parse_date_start_and_end_times(times)
90+
times['EndTime'].should eq('')
91+
end
7492
end

0 commit comments

Comments
 (0)