diff --git a/lib/kaminari/helpers/action_view_extension.rb b/lib/kaminari/helpers/action_view_extension.rb index eaf0e0a..d438eca 100644 --- a/lib/kaminari/helpers/action_view_extension.rb +++ b/lib/kaminari/helpers/action_view_extension.rb @@ -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 diff --git a/spec/helpers/action_view_extension_spec.rb b/spec/helpers/action_view_extension_spec.rb index 6a64dfc..415c659 100644 --- a/spec/helpers/action_view_extension_spec.rb +++ b/spec/helpers/action_view_extension_spec.rb @@ -209,6 +209,18 @@ describe 'Kaminari::ActionViewExtension', :if => defined?(Rails) do it { should == 'Displaying members 26 - 50 of 50 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 31 - 40 of 50 in total' } + end end end context 'on a model with namespace' do