Permalink
Browse files

added spec for link_to_previous_page actionview helper

  • Loading branch information...
1 parent 39f829b commit 9acdf8df03fe8b3d430e35e8de0759c3eedb8d8d @timgremore timgremore committed Dec 29, 2011
Showing with 27 additions and 0 deletions.
  1. +27 −0 spec/helpers/action_view_extension_spec.rb
@@ -16,6 +16,33 @@
end
end
+ describe '#link_to_previous_page' do
+ before do
+ 50.times {|i| User.create! :name => "user#{i}"}
+ end
+ context 'having previous pages' do
+ before do
+ @users = User.page(50)
+ 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 /rel="previous"/ }
+ end
+ context 'overriding rel=' do
+ subject { helper.link_to_previous_page @users, 'Previous', :rel => 'external', :params => {:controller => 'users', :action => 'index'} }
+ it { should match /rel="external"/ }
+ end
+ end
+ context 'the first page' do
+ before do
+ @users = User.page(1)
+ end
+ subject { helper.link_to_previous_page @users, 'Previous', :params => {:controller => 'users', :action => 'index'} }
+ it { should_not be }
+ end
+ end
+
describe '#link_to_next_page' do
before do
50.times {|i| User.create! :name => "user#{i}"}

0 comments on commit 9acdf8d

Please sign in to comment.