Skip to content

Commit 96da226

Browse files
committed
fixed bug in NewsFeedMeta core_fields and core_field_names
Calling either of those methods modified the data array when it should have only been reading the array. Later calls to these methods were then incorrect.
1 parent 14adb9f commit 96da226

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-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.1
2+
- Fixed bug in NewsFeedMeta core_fields and core_field_names. Calling either of those methods modified the data array when it should have only been reading the array. Later calls to these methods were then incorrect.
3+
14
v1.4.0
25
- removed NewsFeedMeta and can_have_newsfeed? from SavedSearch
36

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.0
1+
1.4.1

lib/spark_api/models/news_feed_meta.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def minimum_core_fields
99
end
1010

1111
def core_field_names
12-
fields = data['Subscriptions']['SavedSearches']['CoreSearchFields']
12+
fields = data['Subscriptions']['SavedSearches']['CoreSearchFields'].dup
1313

1414
data['Subscriptions']['SavedSearches']['CoreStandardFields'].each do |field|
1515
fields << field[1]['Label']
@@ -19,7 +19,7 @@ def core_field_names
1919
end
2020

2121
def core_fields
22-
fields = data['Subscriptions']['SavedSearches']['CoreSearchFields']
22+
fields = data['Subscriptions']['SavedSearches']['CoreSearchFields'].dup
2323

2424
data['Subscriptions']['SavedSearches']['CoreStandardFields'].each do |field|
2525
fields << field.first

spec/unit/spark_api/models/news_feed_meta_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
"Year Built", "Total SqFt.", "Sub Type", "Subdivision", "Map Area"]
2323
expect(news_feed_meta.core_field_names).to eq field_array
2424
end
25+
26+
it "doesn't modify the original fields and returns the same results when run twice" do
27+
field_array = ["Location", "Status", "Property Type", "Postal Code", "List Price", "Total Bedrooms",
28+
"Year Built", "Total SqFt.", "Sub Type", "Subdivision", "Map Area"]
29+
expect(news_feed_meta.core_field_names).to eq field_array
30+
expect(news_feed_meta.core_field_names).to eq field_array
31+
end
2532
end
2633

2734
describe 'core_fields' do
@@ -30,6 +37,13 @@
3037
"YearBuilt", "BuildingAreaTotal", "PropertySubType", "SubdivisionName", "MLSAreaMinor"]
3138
expect(news_feed_meta.core_fields).to eq field_array
3239
end
40+
41+
it "doesn't modify the original fields and returns the same results when run twice" do
42+
field_array = ["Location", "MlsStatus", "PropertyType", "PostalCode", "ListPrice", "BedsTotal",
43+
"YearBuilt", "BuildingAreaTotal", "PropertySubType", "SubdivisionName", "MLSAreaMinor"]
44+
expect(news_feed_meta.core_fields).to eq field_array
45+
expect(news_feed_meta.core_fields).to eq field_array
46+
end
3347
end
3448

3549
end

0 commit comments

Comments
 (0)