Merge pull request #712 from igorkasyanchuk/master

hide Next & Last buttons if page is out of range
This commit is contained in:
Yuki Nishijima 2016-07-28 17:59:36 +09:00 committed by GitHub
commit be3a2c9a21
2 changed files with 11 additions and 2 deletions

View File

@ -17,7 +17,9 @@
<%= gap_tag %>
<% end -%>
<% end -%>
<%= next_page_tag unless current_page.last? %>
<%= last_page_tag unless current_page.last? %>
<% unless current_page.out_of_range? %>
<%= next_page_tag unless current_page.last? %>
<%= last_page_tag unless current_page.last? %>
<% end %>
</nav>
<% end -%>

View File

@ -36,6 +36,13 @@ describe 'Kaminari::ActionViewExtension', :if => defined?(::Rails::Railtie) && d
subject { helper.paginate @users, :total_pages => 3, :params => {:controller => 'users', :action => 'index'} }
it { should match(/<a href="\/users\?page=3">Last/) }
end
context "page: 20 (out of range)" do
before { @users = User.page(20) }
subject { helper.paginate @users, :params => {:controller => 'users', :action => 'index'} }
it { should_not match(/Last/) }
it { should_not match(/Next/) }
end
end
describe '#link_to_previous_page' do