diff options
| author | mo khan <mo@mokhan.ca> | 2014-02-20 19:16:17 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-02-20 19:16:17 -0700 |
| commit | 3efbc2b2540783d5d1c9e2a65d423b771f049d6d (patch) | |
| tree | b8cc713d0e3273d6d127364bb7e78ff54c32f714 /spec | |
| parent | f0f7b7ccb7cf67d33a75e97dcdc2e8de5d151544 (diff) | |
return the paginated set of results.
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/models/license_spec.rb | 21 |
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 |
