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

Fix a bug that link_to_next_page behaves like link_to_previous_page

This fixes #530
This commit is contained in:
Yuki Nishijima 2014-03-18 16:57:26 -07:00
parent b42670cc9e
commit fa445f09c1
2 changed files with 5 additions and 5 deletions

View file

@ -62,7 +62,7 @@ module Kaminari
# <span>No More Pages</span>
# <% 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

View file

@ -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