mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
Allow nil for #per, to return records without limit
This commit is contained in:
parent
07cd48d293
commit
949f345a50
2 changed files with 8 additions and 1 deletions
|
@ -3,7 +3,9 @@ module Kaminari
|
|||
# Specify the <tt>per_page</tt> value for the preceding <tt>page</tt> scope
|
||||
# Model.page(3).per(10)
|
||||
def per(num)
|
||||
if (n = num.to_i) <= 0
|
||||
if num.nil?
|
||||
limit(nil)
|
||||
elsif (n = num.to_i) <= 0
|
||||
self
|
||||
elsif max_per_page && max_per_page < n
|
||||
limit(max_per_page).offset(offset_value / limit_value * max_per_page)
|
||||
|
|
|
@ -58,6 +58,11 @@ if defined? ActiveRecord
|
|||
it { should have(5).users }
|
||||
its('first.name') { should == 'user001' }
|
||||
end
|
||||
|
||||
context "page 1 per nil" do
|
||||
subject { model_class.page(1).per(nil) }
|
||||
it { should have(model_class.count).users }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#padding' do
|
||||
|
|
Loading…
Reference in a new issue