+ assert_select "article.diary_post", :count => 20
+ assert_select "li.page-item a.page-link", :text => "Older Entries", :count => 1
+ assert_select "li.page-item a.page-link", :text => "Newer Entries", :count => 1
+
+ # Go back to the first page
+ get css_select("li.page-item .page-link").first["href"]
+ assert_response :success
+ assert_select "article.diary_post", :count => 20
+ assert_select "li.page-item a.page-link", :text => "Older Entries", :count => 1
+ assert_select "li.page-item.disabled span.page-link", :text => "Newer Entries", :count => 1
+ end
+
+ def test_index_invalid_paged
+ # Try some invalid paged accesses
+ %w[-1 0 fred].each do |id|
+ get diary_entries_path(:before => id)
+ assert_redirected_to :controller => :errors, :action => :bad_request
+
+ get diary_entries_path(:after => id)
+ assert_redirected_to :controller => :errors, :action => :bad_request
+ end