summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-02-20 19:16:17 -0700
committermo khan <mo@mokhan.ca>2014-02-20 19:16:17 -0700
commit3efbc2b2540783d5d1c9e2a65d423b771f049d6d (patch)
treeb8cc713d0e3273d6d127364bb7e78ff54c32f714 /spec/models
parentf0f7b7ccb7cf67d33a75e97dcdc2e8de5d151544 (diff)
return the paginated set of results.
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/license_spec.rb21
1 files changed, 19 insertions, 2 deletions
diff --git a/spec/models/license_spec.rb b/spec/models/license_spec.rb
index 9998ad9..a939372 100644
--- a/spec/models/license_spec.rb
+++ b/spec/models/license_spec.rb
@@ -5,11 +5,28 @@ describe License do
let!(:oldest_license) { License.create }
let!(:newest_license) { License.create }
- let(:results) { License.most_recent(1, 2) }
-
it "returns the most recently created well licenses" do
+ results = License.most_recent(page: 1, per_page: 2)
results.first.should == newest_license
results.last.should == oldest_license
end
+
+ it "returns the first page of results" do
+ results = License.most_recent(page: 1, per_page: 1)
+ results.count.should == 1
+ results.first.should == newest_license
+ end
+
+ it "returns the next page of results" do
+ results = License.most_recent(page: 2, per_page: 1)
+ results.count.should == 1
+ results.first.should == oldest_license
+ end
+
+ it "returns the first page of results when the page is below 1" do
+ results = License.most_recent(page: -1, per_page: 1)
+ results.count.should == 1
+ results.first.should == newest_license
+ end
end
end