mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
parent
69e44c6f15
commit
8e48e45aa5
2 changed files with 23 additions and 1 deletions
|
@ -58,7 +58,7 @@ module Kaminari
|
|||
current_page - 1 unless first_page?
|
||||
end
|
||||
|
||||
# First page of the collection ?
|
||||
# First page of the collection?
|
||||
def first_page?
|
||||
current_page == 1
|
||||
end
|
||||
|
@ -67,5 +67,10 @@ module Kaminari
|
|||
def last_page?
|
||||
current_page >= total_pages
|
||||
end
|
||||
|
||||
# Out of range of the collection?
|
||||
def out_of_range?
|
||||
current_page > total_pages
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -201,6 +201,23 @@ if defined? ActiveRecord
|
|||
end
|
||||
end
|
||||
|
||||
describe '#out_of_range?' do
|
||||
context 'on last page' do
|
||||
subject { model_class.page(10).per(10) }
|
||||
its(:out_of_range?) { should == false }
|
||||
end
|
||||
|
||||
context 'within range' do
|
||||
subject { model_class.page(1).per(10) }
|
||||
its(:out_of_range?) { should == false }
|
||||
end
|
||||
|
||||
context 'out of range' do
|
||||
subject { model_class.page(11).per(10) }
|
||||
its(:out_of_range?) { should == true }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#count' do
|
||||
context 'page 1' do
|
||||
subject { model_class.page }
|
||||
|
|
Loading…
Reference in a new issue