flickrmocks 0.8.8 → 0.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.9
|
data/flickrmocks.gemspec
CHANGED
@@ -53,7 +53,7 @@ module FlickrMocks
|
|
53
53
|
def self.commons_institutions_params(params)
|
54
54
|
return {
|
55
55
|
:per_page => params[:per_page] || params[:perpage],
|
56
|
-
:current_page => params[:current_page] || 1
|
56
|
+
:current_page => params[:current_page] || params[:page] || 1
|
57
57
|
}
|
58
58
|
end
|
59
59
|
end
|
@@ -84,8 +84,7 @@ module FlickrMocks
|
|
84
84
|
|
85
85
|
def current_page=(value)
|
86
86
|
page = value.to_i < 1 ? 1 : value.to_i
|
87
|
-
|
88
|
-
max_page = total_entries / @per_page
|
87
|
+
max_page = (total_entries / @per_page) == 0 ? 1 : (total_entries / @per_page)
|
89
88
|
page = page > max_page ? max_page : page
|
90
89
|
@current_page = page
|
91
90
|
end
|
data/spec/api/options_spec.rb
CHANGED
@@ -165,6 +165,14 @@ describe APP::Api do
|
|
165
165
|
subject.commons_institutions_params(:per_page => 20).should ==
|
166
166
|
{:per_page => 20, :current_page => 1}
|
167
167
|
end
|
168
|
+
it "returns :current_page in preference to :page" do
|
169
|
+
subject.commons_institutions_params(:per_page=>20,:page=>2,:current_page=>3).should ==
|
170
|
+
{:per_page => 20, :current_page => 3}
|
171
|
+
end
|
172
|
+
it "returns :page when :current_page is not specified" do
|
173
|
+
subject.commons_institutions_params(:per_page=>20,:page=>3).should ==
|
174
|
+
{:per_page => 20, :current_page => 3}
|
175
|
+
end
|
168
176
|
end
|
169
177
|
|
170
178
|
|
@@ -62,6 +62,9 @@ describe APP::CommonsInstitutions do
|
|
62
62
|
klass.new(fixture,:per_page => 20,
|
63
63
|
:current_page => max_page+1).current_page.should == max_page
|
64
64
|
end
|
65
|
+
it "should return 1 when :per_page is very large and current_page is not set" do
|
66
|
+
klass.new(fixture,:per_page => 200000).current_page.should == 1
|
67
|
+
end
|
65
68
|
end
|
66
69
|
|
67
70
|
specify {subject.should respond_to(:per_page)}
|