Skip to content

Commit

Permalink
MWEB-2568 - Update check for empty string (#165)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
Bernardo Anderson and Bernardo Anderson authored Mar 31, 2020
1 parent f8b16cd commit 4c8200e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v1.4.32
- Updated check on Open Houses and Tour of Homes for empty string

v1.4.31
- Updated requests to allow arrays as a body

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.31
1.4.32
4 changes: 2 additions & 2 deletions lib/spark_api/models/subresource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def find_by_id(id, parent_id, arguments={})

def parse_date_start_and_end_times(attributes)
# Transform the date strings
unless attributes['Date'].nil?
unless attributes['Date'].nil? || attributes['Date'].empty?
date = Date.strptime attributes['Date'], '%m/%d/%Y'
['StartTime','EndTime'].each do |time|
next if attributes[time].nil?
next if attributes[time].nil? || attributes[time].empty?
formatted_date = "#{attributes['Date']}T#{attributes[time]}"
datetime = nil

Expand Down
18 changes: 18 additions & 0 deletions spec/unit/spark_api/models/subresource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,22 @@

expect {dummy_class.parse_date_start_and_end_times(times)}.to raise_error(ArgumentError)
end

it "should ignore an empty Date" do
times = {'Date' => '', 'StartTime' => '09:12:34-0700', 'EndTime' => '12:43:21-0700'}
dummy_class.parse_date_start_and_end_times(times)
times['Date'].should eq('')
end

it "should ignore an empty StartTime" do
times = {'Date' => '10/01/2012', 'StartTime' => '', 'EndTime' => '12:43:21-0700'}
dummy_class.parse_date_start_and_end_times(times)
times['StartTime'].should eq('')
end

it "should ignore an empty EndTime" do
times = {'Date' => '10/01/2012', 'StartTime' => '09:12:34-0700', 'EndTime' => ''}
dummy_class.parse_date_start_and_end_times(times)
times['EndTime'].should eq('')
end
end

0 comments on commit 4c8200e

Please sign in to comment.