Skip to content

Commit 9d4c7fc

Browse files
committed
removed unnecessary and broken provided_search? method in SavedSearch
1 parent b23d49f commit 9d4c7fc

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

lib/spark_api/models/saved_search.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ def self.provided()
2424
Class.new(self).tap do |provided|
2525
provided.element_name = '/savedsearches'
2626
provided.prefix = '/provided'
27-
def provided_search?
28-
true
29-
end
3027
SparkApi.logger.info("#{self.name}.path: #{provided.path}")
3128
end
3229
end
@@ -70,7 +67,7 @@ def contacts
7067

7168
def listings(args = {})
7269
arguments = {:_filter => "SavedSearch Eq '#{self.Id}'"}
73-
arguments.merge!(:RequestMode => 'permissive') if provided_search?
70+
arguments.merge!(:RequestMode => 'permissive') if Provided?
7471
@listings ||= Listing.collect(connection.get("/listings", arguments.merge(args)))
7572
end
7673

@@ -79,10 +76,6 @@ def newsfeeds
7976
:_expand => "NewsFeeds").first["NewsFeeds"])
8077
end
8178

82-
def provided_search?
83-
false
84-
end
85-
8679
def can_have_newsfeed?
8780

8881
return true if has_active_newsfeed? || has_inactive_newsfeed?

spec/fixtures/saved_searches/get.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"Filter": "City Eq 'Moorhead' And MlsStatus Eq 'Active' And PropertyType Eq 'A'",
1010
"ContactIds": [
1111
"20100815220615294367000000"
12-
]
12+
],
13+
"Provided": false
1314
},
1415
{
1516
"ResourceUri": "/v1/savedsearches/20100615220615292711000000",
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"D": {
3+
"Success": true,
4+
"Results": [
5+
{
6+
"ResourceUri": "/v1/savedsearches/20100815220615294367000000",
7+
"Id": "20100815220615294367000000",
8+
"Name": "Search name here",
9+
"Filter": "City Eq 'Moorhead' And MlsStatus Eq 'Active' And PropertyType Eq 'A'",
10+
"ContactIds": [
11+
"20100815220615294367000000"
12+
],
13+
"Provided": true
14+
},
15+
{
16+
"ResourceUri": "/v1/savedsearches/20100615220615292711000000",
17+
"Id": "20100615220615292711000000",
18+
"Name": "Second search name here"
19+
}
20+
]
21+
}
22+
}

spec/unit/spark_api/models/saved_search_spec.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
end
112112

113113
it "should include the permissive parameter for provided searches" do
114-
stub_api_get("/provided/savedsearches/#{id}", 'saved_searches/get.json')
114+
stub_api_get("/provided/savedsearches/#{id}", 'saved_searches/get_provided.json')
115115
resource = subject.class.provided.find(id)
116116
expect(SparkApi.client).to receive(:get).with("/listings",
117117
{:_filter => "SavedSearch Eq '#{id}'", :RequestMode => 'permissive'})
@@ -121,7 +121,6 @@
121121
it "should not include the permissive parameter for saved searches" do
122122
stub_api_get("/#{subject.class.element_name}/#{id}", 'saved_searches/get.json')
123123
resource = subject.class.find(id)
124-
resource.stub(:provided_search?) { false }
125124
expect(SparkApi.client).to receive(:get).with("/listings", {:_filter => "SavedSearch Eq '#{id}'"})
126125
resource.listings
127126
end
@@ -191,7 +190,6 @@
191190
it "should return true with three filter parameters" do
192191
stub_api_get("/#{subject.class.element_name}/#{id}", 'saved_searches/get.json')
193192
resource = subject.class.find(id)
194-
resource.stub(:provided_search?) { false }
195193
resource.stub(:has_active_newsfeed?) { false }
196194
resource.stub(:has_inactive_newsfeed?) { false }
197195
resource.can_have_newsfeed?.should == true
@@ -205,7 +203,6 @@
205203
stub_api_get("/#{subject.class.element_name}/#{id}", 'saved_searches/with_newsfeed.json',
206204
{ "_expand" => "NewsFeedSubscriptionSummary" } )
207205
resource = subject.class.find(id)
208-
resource.stub(:provided_search?) { false }
209206
resource.has_active_newsfeed?.should == true
210207
end
211208

@@ -214,7 +211,6 @@
214211
stub_api_get("/#{subject.class.element_name}/#{id}", 'saved_searches/without_newsfeed.json',
215212
{ "_expand" => "NewsFeedSubscriptionSummary" } )
216213
resource = subject.class.find(id)
217-
resource.stub(:provided_search?) { false }
218214
resource.has_active_newsfeed?.should == false
219215
end
220216
end
@@ -225,7 +221,6 @@
225221
stub_api_get("/#{subject.class.element_name}/#{id}", 'saved_searches/with_inactive_newsfeed.json',
226222
{ "_expand" => "NewsFeedSubscriptionSummary" } )
227223
resource = subject.class.find(id)
228-
resource.stub(:provided_search?) { false }
229224
resource.has_inactive_newsfeed?.should == true
230225
end
231226

@@ -234,7 +229,6 @@
234229
stub_api_get("/#{subject.class.element_name}/#{id}", 'saved_searches/without_newsfeed.json',
235230
{ "_expand" => "NewsFeedSubscriptionSummary, NewsFeeds" } )
236231
resource = subject.class.find(id)
237-
# resource.stub(:provided_search?) { false }
238232
resource.has_inactive_newsfeed?.should == false
239233
end
240234

0 commit comments

Comments
 (0)