fixes #2 show nothing when num_page == 1
This commit is contained in:
parent
e6481a1c89
commit
23186e5c9c
|
@ -67,6 +67,7 @@ module Kaminari
|
||||||
|
|
||||||
def tagify_links
|
def tagify_links
|
||||||
num_pages, current_page, left, window, right = @options[:num_pages], @options[:current_page], @left, @window, @right
|
num_pages, current_page, left, window, right = @options[:num_pages], @options[:current_page], @left, @window, @right
|
||||||
|
return [] if num_pages <= 1
|
||||||
|
|
||||||
tags = []
|
tags = []
|
||||||
tags << (current_page > 1 ? PrevLink.new(self) : PrevSpan.new(self))
|
tags << (current_page > 1 ? PrevLink.new(self) : PrevSpan.new(self))
|
||||||
|
|
|
@ -15,6 +15,12 @@ describe 'Kaminari::Helpers::PaginationRenderer' do
|
||||||
PaginationRenderer.new(renderer, options).tagify_links
|
PaginationRenderer.new(renderer, options).tagify_links
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context '1 page in total' do
|
||||||
|
subject { tags_with :num_pages => 1, :current_page => 1 }
|
||||||
|
it { should have(0).tags }
|
||||||
|
end
|
||||||
|
|
||||||
|
context '10 pages in total' do
|
||||||
context 'first page' do
|
context 'first page' do
|
||||||
subject { tags_with :num_pages => 10, :current_page => 1 }
|
subject { tags_with :num_pages => 10, :current_page => 1 }
|
||||||
it { should_not contain_tag PrevLink }
|
it { should_not contain_tag PrevLink }
|
||||||
|
@ -106,4 +112,5 @@ describe 'Kaminari::Helpers::PaginationRenderer' do
|
||||||
it { should contain_tag TruncatedSpan }
|
it { should contain_tag TruncatedSpan }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue