-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #274 from keiko713/max_per_page
Add max_per_page config value
- Loading branch information
Showing
6 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'spec_helper' | ||
|
||
if defined? ActiveRecord | ||
|
||
describe 'max per_page' do | ||
describe 'AR::Base' do | ||
subject { ActiveRecord::Base } | ||
it { should_not respond_to :max_paginates_per } | ||
end | ||
|
||
subject { User.page(0).per(100) } | ||
|
||
context 'by default' do | ||
its(:limit_value) { should == 100 } | ||
end | ||
|
||
context 'when explicitly set via max_paginates_per' do | ||
before { User.max_paginates_per 10 } | ||
its(:limit_value) { should == 10 } | ||
after { User.max_paginates_per nil } | ||
end | ||
|
||
describe "max per_page value's independency per model" do | ||
context "when User's max per_page was changed" do | ||
before { User.max_paginates_per 10 } | ||
subject { Book.page(0).per(100) } | ||
its(:limit_value) { should == 100 } | ||
after { User.max_paginates_per nil } | ||
end | ||
end | ||
end | ||
end |