Merge pull request #712 from igorkasyanchuk/master
hide Next & Last buttons if page is out of range
This commit is contained in:
commit
be3a2c9a21
|
@ -17,7 +17,9 @@
|
||||||
<%= gap_tag %>
|
<%= gap_tag %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<%= next_page_tag unless current_page.last? %>
|
<% unless current_page.out_of_range? %>
|
||||||
<%= last_page_tag unless current_page.last? %>
|
<%= next_page_tag unless current_page.last? %>
|
||||||
|
<%= last_page_tag unless current_page.last? %>
|
||||||
|
<% end %>
|
||||||
</nav>
|
</nav>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
|
@ -36,6 +36,13 @@ describe 'Kaminari::ActionViewExtension', :if => defined?(::Rails::Railtie) && d
|
||||||
subject { helper.paginate @users, :total_pages => 3, :params => {:controller => 'users', :action => 'index'} }
|
subject { helper.paginate @users, :total_pages => 3, :params => {:controller => 'users', :action => 'index'} }
|
||||||
it { should match(/<a href="\/users\?page=3">Last/) }
|
it { should match(/<a href="\/users\?page=3">Last/) }
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe '#link_to_previous_page' do
|
describe '#link_to_previous_page' do
|
||||||
|
|
Loading…
Reference in New Issue