diff --git a/lib/kaminari/helpers/action_view_extension.rb b/lib/kaminari/helpers/action_view_extension.rb
index f5008cf..d6e0b4c 100644
--- a/lib/kaminari/helpers/action_view_extension.rb
+++ b/lib/kaminari/helpers/action_view_extension.rb
@@ -117,13 +117,12 @@ module Kaminari
# #->
#
def rel_next_prev_link_tags(scope, options = {})
- params = options.delete(:params) || {}
- param_name = options.delete(:param_name) || Kaminari.config.param_name
+ next_page = Kaminari::Helpers::NextPage.new self, options.reverse_merge(:current_page => scope.current_page)
+ prev_page = Kaminari::Helpers::PrevPage.new self, options.reverse_merge(:current_page => scope.current_page)
output = ""
- output << '' if scope.next_page
- output << '' if scope.prev_page
-
+ output << tag(:link, :rel => "next", :href => next_page.url) if scope.next_page
+ output << tag(:link, :rel => "prev", :href => prev_page.url) if scope.prev_page
output.html_safe
end
end
diff --git a/spec/helpers/action_view_extension_spec.rb b/spec/helpers/action_view_extension_spec.rb
index 94b74fe..75b3e29 100644
--- a/spec/helpers/action_view_extension_spec.rb
+++ b/spec/helpers/action_view_extension_spec.rb
@@ -266,38 +266,31 @@ describe 'Kaminari::ActionViewExtension', :if => defined?(Rails) do
describe '#rel_next_prev_link_tags' do
before do
- 80.times {|i| User.create! :name => "user#{i}"}
+ 31.times {|i| User.create! :name => "user#{i}"}
end
- context 'the first page' do
- before do
- @users = User.page(1).per(25)
- end
+ subject { helper.rel_next_prev_link_tags users, :params => {:controller => 'users', :action => 'index'} }
+
+ context 'the first page' do
+ let(:users) { User.page(1).per(10) }
- subject { helper.rel_next_prev_link_tags @users, :params => {:controller => 'users', :action => 'index'} }
it { should_not match(/rel="prev"/) }
it { should match(/rel="next"/) }
it { should match(/\?page=2/) }
end
- context 'the middle page' do
- before do
- @users = User.page(3).per(25)
- end
+ context 'the second page' do
+ let(:users) { User.page(2).per(10) }
- subject { helper.rel_next_prev_link_tags @users, :params => {:controller => 'users', :action => 'index'} }
it { should match(/rel="prev"/) }
- it { should match(/\?page=2/) }
+ it { should_not match(/\?page=1/) }
it { should match(/rel="next"/) }
- it { should match(/\?page=4/) }
+ it { should match(/\?page=3/) }
end
context 'the last page' do
- before do
- @users = User.page(4).per(25)
- end
+ let(:users) { User.page(4).per(10) }
- subject { helper.rel_next_prev_link_tags @users, :params => {:controller => 'users', :action => 'index'} }
it { should match(/rel="prev"/) }
it { should match(/\?page=3"/) }
it { should_not match(/rel="next"/) }