|
99 | 99 | resource.ContactIds.size.should eq(0)
|
100 | 100 | end
|
101 | 101 |
|
| 102 | + describe "listings" do |
| 103 | + |
| 104 | + it "should return the searches listings" do |
| 105 | + stub_api_get("/#{subject.class.element_name}/#{id}", 'saved_searches/get.json') |
| 106 | + stub_api_get("/listings", 'listings/multiple.json', |
| 107 | + {:_filter => "City Eq 'Moorhead' And MlsStatus Eq 'Active' And PropertyType Eq 'A'"}) |
| 108 | + listings = subject.class.find(id).listings |
| 109 | + listings.should be_an(Array) |
| 110 | + listings[0].should be_a(Listing) |
| 111 | + end |
| 112 | + |
| 113 | + it "should include the permissive parameter for provided searches" do |
| 114 | + stub_api_get("/provided/savedsearches/#{id}", 'saved_searches/get.json') |
| 115 | + resource = subject.class.provided.find(id) |
| 116 | + expect(SparkApi.client).to receive(:get).with("/listings", |
| 117 | + {:_filter => resource.Filter, :RequestMode => 'permissive'}) |
| 118 | + resource.listings |
| 119 | + end |
| 120 | + |
| 121 | + end |
| 122 | + |
102 | 123 | end
|
103 | 124 |
|
104 | 125 | context "/provided/savedsearches", :support do
|
|
139 | 160 | describe "can_have_newsfeed?" do
|
140 | 161 |
|
141 | 162 | it "should return false for a provided search" do
|
142 |
| - stub_api_get("/#{subject.class.element_name}/#{id}", 'saved_searches/get.json') |
143 |
| - resource = subject.class.find(id) |
144 |
| - resource.stub(:provided_search?) { true } |
| 163 | + stub_api_get("/provided/#{subject.class.element_name}/#{id}", 'saved_searches/get.json') |
| 164 | + resource = subject.class.provided.find(id) |
145 | 165 | resource.can_have_newsfeed?.should == false
|
146 | 166 | end
|
147 | 167 |
|
148 | 168 | it "should return false without at least three filter parameters" do
|
149 | 169 | stub_api_get("/#{subject.class.element_name}/#{id}", 'saved_searches/get.json')
|
150 | 170 | resource = subject.class.find(id)
|
151 |
| - resource.stub(:provided_search?) { false } |
152 |
| - resource.stub(:has_active_newsfeed?) { false } |
153 |
| - resource.stub(:has_inactive_newsfeed?) { false } |
154 | 171 | resource.Filter = "City Eq 'Moorhead' And MlsStatus Eq 'Active'"
|
155 | 172 | resource.can_have_newsfeed?.should == false
|
156 | 173 | end
|
|
177 | 194 | end
|
178 | 195 |
|
179 | 196 | it "should return false for a provided search" do
|
180 |
| - stub_api_get("/#{subject.class.element_name}/#{id}", 'saved_searches/get.json') |
181 |
| - resource = subject.class.find(id) |
182 |
| - resource.stub(:provided_search?) { true } |
| 197 | + stub_api_get("/provided/#{subject.class.element_name}/#{id}", 'saved_searches/get.json') |
| 198 | + resource = subject.class.provided.find(id) |
183 | 199 | resource.has_active_newsfeed?.should == false
|
184 | 200 | end
|
185 | 201 | end
|
|
195 | 211 | end
|
196 | 212 |
|
197 | 213 | it "should return false for a provided search" do
|
198 |
| - stub_api_get("/#{subject.class.element_name}/#{id}", 'saved_searches/with_inactive_newsfeed.json') |
199 |
| - resource = subject.class.find(id) |
200 |
| - resource.stub(:provided_search?) { true } |
| 214 | + stub_api_get("/provided/#{subject.class.element_name}/#{id}", 'saved_searches/with_inactive_newsfeed.json') |
| 215 | + resource = subject.class.provided.find(id) |
201 | 216 | resource.has_inactive_newsfeed?.should == false
|
202 | 217 | end
|
203 | 218 | end
|
|
0 commit comments