no longer displays pagination info if paginated object is empty

pull/175/head
Jens Ulferts 12 years ago
parent f82de2e7ed
commit 22435317c4
  1. 11
      app/helpers/pagination_helper.rb
  2. 8
      spec/helpers/pagination_helper.rb

@ -15,12 +15,15 @@ require 'will_paginate'
module PaginationHelper
def pagination_links_full(paginator, count=nil, options={})
html = ''.html_safe
html << will_paginate(paginator, next_label: I18n.t(:label_next), previous_label: I18n.t(:label_next), :container => false)
html << content_tag(:span, "(#{paginator.offset + 1} - #{paginator.offset + paginator.length}/#{paginator.total_entries})", :class => 'range')
if paginator.total_entries > 0
html << will_paginate(paginator, next_label: I18n.t(:label_next), previous_label: I18n.t(:label_next), :container => false)
if per_page_links && links = per_page_links(paginator.per_page)
html << links
html << content_tag(:span, "(#{paginator.offset + 1} - #{paginator.offset + paginator.length}/#{paginator.total_entries})", :class => 'range')
if per_page_links && links = per_page_links(paginator.per_page)
html << links
end
end
content_tag :p, html, :class => "pagination"

@ -102,5 +102,13 @@ describe PaginationHelper do
end
end
describe "WHEN the paginated object is empty" do
let(:total_entries) { 0 }
it "should be empty" do
pagination.should have_selector(".pagination", :text => /^$/)
end
end
end
end

Loading…
Cancel
Save