1
0
Fork 0
mirror of https://github.com/kaminari/kaminari.git synced 2022-11-09 13:44:37 -05:00

Fixed a bug where the range of the records displayed on the last page doesn't match

closes #718
This commit is contained in:
Yuki Nishijima 2016-05-08 22:23:36 +00:00
parent 03ffb28ec3
commit 17d0fb83aa
2 changed files with 13 additions and 1 deletions

View file

@ -95,7 +95,7 @@ module Kaminari
t('helpers.page_entries_info.one_page.display_entries', :entry_name => entry_name, :count => collection.total_count)
else
first = collection.offset_value + 1
last = collection.last_page? ? collection.total_count : collection.offset_value + collection.limit_value
last = (sum = collection.offset_value + collection.limit_value) > collection.total_count ? collection.total_count : sum
t('helpers.page_entries_info.more_pages.display_entries', :entry_name => entry_name, :first => first, :last => last, :total => collection.total_count)
end.html_safe
end

View file

@ -209,6 +209,18 @@ describe 'Kaminari::ActionViewExtension', :if => defined?(Rails) do
it { should == 'Displaying members <b>26&nbsp;-&nbsp;50</b> of <b>50</b> in total' }
end
end
describe 'the last page' do
before do
User.max_pages_per 4
@users = User.page(4).per(10)
end
after { User.max_pages_per nil }
subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} }
it { should == 'Displaying users <b>31&nbsp;-&nbsp;40</b> of <b>50</b> in total' }
end
end
end
context 'on a model with namespace' do