rentjuicer 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rentjuicer/listings.rb +6 -2
- data/rentjuicer.gemspec +1 -1
- data/spec/rentjuicer/response_spec.rb +5 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.2
|
data/lib/rentjuicer/listings.rb
CHANGED
@@ -32,7 +32,7 @@ module Rentjuicer
|
|
32
32
|
response = search(params)
|
33
33
|
if response.success?
|
34
34
|
all_listings << response.properties
|
35
|
-
total_pages = (response.
|
35
|
+
total_pages = (response.total_results/per_page.to_f).ceil
|
36
36
|
if total_pages > 1
|
37
37
|
(2..total_pages).each do |page_num|
|
38
38
|
resp = search(params.merge(:page => page_num))
|
@@ -75,6 +75,10 @@ module Rentjuicer
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
+
def total_results
|
79
|
+
self.body.total_count ? self.body.total_count : properties.size
|
80
|
+
end
|
81
|
+
|
78
82
|
def mls_results?
|
79
83
|
@has_mls_properties ||= properties.any?{|property| property.mls_listing?}
|
80
84
|
end
|
@@ -88,7 +92,7 @@ module Rentjuicer
|
|
88
92
|
self.paginator_cache = WillPaginate::Collection.create(
|
89
93
|
self.body.page ||= 1,
|
90
94
|
@limit,
|
91
|
-
|
95
|
+
self.total_results) do |pager|
|
92
96
|
pager.replace properties
|
93
97
|
end
|
94
98
|
end
|
data/rentjuicer.gemspec
CHANGED
@@ -65,6 +65,11 @@ describe Rentjuicer::Response do
|
|
65
65
|
@results.body = body
|
66
66
|
@results.total_count.should == 25
|
67
67
|
end
|
68
|
+
|
69
|
+
it "should return @properties.size when total_count is nil for total_results" do
|
70
|
+
@results.body.stub!(:total_count).and_return(nil)
|
71
|
+
@results.total_results.should == 20
|
72
|
+
end
|
68
73
|
|
69
74
|
it "should call super if body does not response to the method" do
|
70
75
|
lambda { @results.bad_method }.should raise_error(NoMethodError, /undefined method `bad_method'/)
|
metadata
CHANGED