you_got_listed 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,7 +13,7 @@ module YouGotListed
13
13
  self.client = client
14
14
  end
15
15
 
16
- def similar_listings(limit = 6)
16
+ def similar_listings(limit = 6, search_options = {})
17
17
  min_baths = ((self.baths.to_i - 1) <= 0 ? 0 : (self.baths.to_i - 1))
18
18
  max_baths = self.baths.to_i + 1
19
19
  min_rent = (self.price.to_i * 0.9).to_i
@@ -28,14 +28,16 @@ module YouGotListed
28
28
  :max_bed => max_beds,
29
29
  :baths => [min_baths, self.baths, max_baths].join(','),
30
30
  :city_neighborhood => self.city_neighborhood
31
- }
32
- similar = []
33
- listings = YouGotListed::Listings.new(self.client)
34
- listings.search(search_params).properties.each do |prop|
35
- similar << prop unless prop.id == self.id
36
- break if similar.size == limit
31
+ }.merge(search_options)
32
+ @cached_similars ||= begin
33
+ similar = []
34
+ listings = YouGotListed::Listings.new(self.client)
35
+ listings.search(search_params).properties.each do |prop|
36
+ similar << prop unless prop.id == self.id
37
+ break if similar.size == limit
38
+ end
39
+ similar
37
40
  end
38
- similar
39
41
  end
40
42
 
41
43
  def town_neighborhood
@@ -1,3 +1,3 @@
1
1
  module YouGotListed
2
- VERSION = '0.3.5'
2
+ VERSION = '0.3.6'
3
3
  end
@@ -61,6 +61,20 @@ describe YouGotListed::Listing do
61
61
  end
62
62
  end
63
63
 
64
+ context "similar listings with custom params" do
65
+ before do
66
+ VCR.use_cassette('listing.similar_listings_custom') do
67
+ @similar_props = @listing.similar_listings(4, :include_mls => "1")
68
+ end
69
+ end
70
+
71
+ it "should return an array of listings" do
72
+ @similar_props.should be_kind_of(Array)
73
+ @similar_props.should have_at_most(4).listings
74
+ @similar_props.collect{|x| x.id}.should_not include(@listing.id)
75
+ end
76
+ end
77
+
64
78
  context "empty response" do
65
79
  before do
66
80
  min_baths = ((@listing.baths.to_i - 1) <= 0 ? 0 : (@listing.baths.to_i - 1))
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: you_got_listed
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 5
10
- version: 0.3.5
9
+ - 6
10
+ version: 0.3.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tom Cocca