diff --git a/lib/kaminari/helpers/action_view_extension.rb b/lib/kaminari/helpers/action_view_extension.rb index e7e4d46..b3381e8 100644 --- a/lib/kaminari/helpers/action_view_extension.rb +++ b/lib/kaminari/helpers/action_view_extension.rb @@ -62,7 +62,7 @@ module Kaminari # No More Pages # <% end %> def link_to_next_page(scope, name, options = {}, &block) - next_page = Kaminari::Helpers::PrevPage.new self, options.reverse_merge(:current_page => scope.current_page, :total_pages => scope.total_pages, :per_page => scope.limit_value, :remote => false) + next_page = Kaminari::Helpers::NextPage.new self, options.reverse_merge(:current_page => scope.current_page, :total_pages => scope.total_pages, :per_page => scope.limit_value, :remote => false) link_to_unless scope.last_page?, name, next_page.url, next_page.options.reverse_merge(:rel => 'next') do block.call if block diff --git a/spec/helpers/action_view_extension_spec.rb b/spec/helpers/action_view_extension_spec.rb index 95b0a1d..0edca9b 100644 --- a/spec/helpers/action_view_extension_spec.rb +++ b/spec/helpers/action_view_extension_spec.rb @@ -19,17 +19,17 @@ describe 'Kaminari::ActionViewExtension', :if => defined?(Rails) do describe '#link_to_previous_page' do before do - 50.times {|i| User.create! :name => "user#{i}"} + 60.times {|i| User.create! :name => "user#{i}"} end context 'having previous pages' do before do - @users = User.page(50) + @users = User.page(3) end context 'the default behaviour' do subject { helper.link_to_previous_page @users, 'Previous', :params => {:controller => 'users', :action => 'index'} } - it { should be_a String } + it { should match(/page=2/) } it { should match(/rel="previous"/) } end @@ -70,7 +70,7 @@ describe 'Kaminari::ActionViewExtension', :if => defined?(Rails) do context 'the default behaviour' do subject { helper.link_to_next_page @users, 'More', :params => {:controller => 'users', :action => 'index'} } - it { should be_a String } + it { should match(/page=2/) } it { should match(/rel="next"/) } end