Make sure that link_to_{previous,next}_page work for every view adapter

This commit is contained in:
Akira Matsuda 2016-11-23 20:15:56 +09:00
parent 8b9e5382ef
commit b2b4c01fa5
2 changed files with 14 additions and 0 deletions

View File

@ -35,6 +35,8 @@ class UsersController < ApplicationController
@users = User.page params[:page]
render inline: <<-ERB
<%= @users.map(&:name).join("\n") %>
<%= link_to_previous_page @users, 'previous page', class: 'prev' %>
<%= link_to_next_page @users, 'next page', class: 'next' %>
<%= paginate @users %>
<div class="info"><%= page_entries_info @users %></div>
ERB

View File

@ -18,6 +18,9 @@ class NavigationTest < Test::Unit::TestCase
test 'navigating by pagination links' do
visit '/users'
assert page.has_no_content? 'previous page'
assert page.has_content? 'next page'
within 'nav.pagination' do
within 'span.page.current' do
assert page.has_content? '1'
@ -27,6 +30,9 @@ class NavigationTest < Test::Unit::TestCase
end
end
assert page.has_content? 'previous page'
assert page.has_content? 'next page'
within 'nav.pagination' do
within 'span.page.current' do
assert page.has_content? '2'
@ -36,6 +42,9 @@ class NavigationTest < Test::Unit::TestCase
end
end
assert page.has_content? 'previous page'
assert page.has_no_content? 'next page'
within 'nav.pagination' do
within 'span.page.current' do
assert page.has_content? '4'
@ -45,6 +54,9 @@ class NavigationTest < Test::Unit::TestCase
end
end
assert page.has_content? 'previous page'
assert page.has_content? 'next page'
within 'nav.pagination' do
within 'span.page.current' do
assert page.has_content? '3'