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
|
||||
num_pages, current_page, left, window, right = @options[:num_pages], @options[:current_page], @left, @window, @right
|
||||
return [] if num_pages <= 1
|
||||
|
||||
tags = []
|
||||
tags << (current_page > 1 ? PrevLink.new(self) : PrevSpan.new(self))
|
||||
|
|
|
@ -15,95 +15,102 @@ describe 'Kaminari::Helpers::PaginationRenderer' do
|
|||
PaginationRenderer.new(renderer, options).tagify_links
|
||||
end
|
||||
|
||||
context 'first page' do
|
||||
subject { tags_with :num_pages => 10, :current_page => 1 }
|
||||
it { should_not contain_tag PrevLink }
|
||||
it { should contain_tag PrevSpan }
|
||||
it { should contain_tag CurrentPage }
|
||||
it { should_not contain_tag FirstPageLink }
|
||||
it { should contain_tag LastPageLink }
|
||||
it { should contain_tag PageLink }
|
||||
it { should contain_tag NextLink }
|
||||
it { should_not contain_tag NextSpan }
|
||||
it { should contain_tag TruncatedSpan }
|
||||
context '1 page in total' do
|
||||
subject { tags_with :num_pages => 1, :current_page => 1 }
|
||||
it { should have(0).tags }
|
||||
end
|
||||
|
||||
context 'second page' do
|
||||
subject { tags_with :num_pages => 10, :current_page => 2 }
|
||||
it { should contain_tag PrevLink }
|
||||
it { should_not contain_tag PrevSpan }
|
||||
it { should contain_tag CurrentPage }
|
||||
it { should contain_tag FirstPageLink }
|
||||
it { should contain_tag LastPageLink }
|
||||
it { should contain_tag PageLink }
|
||||
it { should contain_tag NextLink }
|
||||
it { should_not contain_tag NextSpan }
|
||||
it { should contain_tag TruncatedSpan }
|
||||
end
|
||||
context '10 pages in total' do
|
||||
context 'first page' do
|
||||
subject { tags_with :num_pages => 10, :current_page => 1 }
|
||||
it { should_not contain_tag PrevLink }
|
||||
it { should contain_tag PrevSpan }
|
||||
it { should contain_tag CurrentPage }
|
||||
it { should_not contain_tag FirstPageLink }
|
||||
it { should contain_tag LastPageLink }
|
||||
it { should contain_tag PageLink }
|
||||
it { should contain_tag NextLink }
|
||||
it { should_not contain_tag NextSpan }
|
||||
it { should contain_tag TruncatedSpan }
|
||||
end
|
||||
|
||||
context 'third page' do
|
||||
subject { tags_with :num_pages => 10, :current_page => 3 }
|
||||
it { should contain_tag PrevLink }
|
||||
it { should_not contain_tag PrevSpan }
|
||||
it { should contain_tag CurrentPage }
|
||||
it { should contain_tag FirstPageLink }
|
||||
it { should contain_tag LastPageLink }
|
||||
it { should contain_tag PageLink }
|
||||
it { should contain_tag NextLink }
|
||||
it { should_not contain_tag NextSpan }
|
||||
it { should contain_tag TruncatedSpan }
|
||||
end
|
||||
context 'second page' do
|
||||
subject { tags_with :num_pages => 10, :current_page => 2 }
|
||||
it { should contain_tag PrevLink }
|
||||
it { should_not contain_tag PrevSpan }
|
||||
it { should contain_tag CurrentPage }
|
||||
it { should contain_tag FirstPageLink }
|
||||
it { should contain_tag LastPageLink }
|
||||
it { should contain_tag PageLink }
|
||||
it { should contain_tag NextLink }
|
||||
it { should_not contain_tag NextSpan }
|
||||
it { should contain_tag TruncatedSpan }
|
||||
end
|
||||
|
||||
context 'fourth page(no truncation)' do
|
||||
subject { tags_with :num_pages => 10, :current_page => 4 }
|
||||
it { should contain_tag PrevLink }
|
||||
it { should_not contain_tag PrevSpan }
|
||||
it { should contain_tag CurrentPage }
|
||||
it { should contain_tag FirstPageLink }
|
||||
it { should contain_tag LastPageLink }
|
||||
it { should contain_tag PageLink }
|
||||
it { should contain_tag NextLink }
|
||||
it { should_not contain_tag NextSpan }
|
||||
it { should_not contain_tag TruncatedSpan }
|
||||
end
|
||||
context 'third page' do
|
||||
subject { tags_with :num_pages => 10, :current_page => 3 }
|
||||
it { should contain_tag PrevLink }
|
||||
it { should_not contain_tag PrevSpan }
|
||||
it { should contain_tag CurrentPage }
|
||||
it { should contain_tag FirstPageLink }
|
||||
it { should contain_tag LastPageLink }
|
||||
it { should contain_tag PageLink }
|
||||
it { should contain_tag NextLink }
|
||||
it { should_not contain_tag NextSpan }
|
||||
it { should contain_tag TruncatedSpan }
|
||||
end
|
||||
|
||||
context 'seventh page(no truncation)' do
|
||||
subject { tags_with :num_pages => 10, :current_page => 7 }
|
||||
it { should contain_tag PrevLink }
|
||||
it { should_not contain_tag PrevSpan }
|
||||
it { should contain_tag CurrentPage }
|
||||
it { should contain_tag FirstPageLink }
|
||||
it { should contain_tag LastPageLink }
|
||||
it { should contain_tag PageLink }
|
||||
it { should contain_tag NextLink }
|
||||
it { should_not contain_tag NextSpan }
|
||||
it { should_not contain_tag TruncatedSpan }
|
||||
end
|
||||
context 'fourth page(no truncation)' do
|
||||
subject { tags_with :num_pages => 10, :current_page => 4 }
|
||||
it { should contain_tag PrevLink }
|
||||
it { should_not contain_tag PrevSpan }
|
||||
it { should contain_tag CurrentPage }
|
||||
it { should contain_tag FirstPageLink }
|
||||
it { should contain_tag LastPageLink }
|
||||
it { should contain_tag PageLink }
|
||||
it { should contain_tag NextLink }
|
||||
it { should_not contain_tag NextSpan }
|
||||
it { should_not contain_tag TruncatedSpan }
|
||||
end
|
||||
|
||||
context 'eighth page' do
|
||||
subject { tags_with :num_pages => 10, :current_page => 8 }
|
||||
it { should contain_tag PrevLink }
|
||||
it { should_not contain_tag PrevSpan }
|
||||
it { should contain_tag CurrentPage }
|
||||
it { should contain_tag FirstPageLink }
|
||||
it { should contain_tag LastPageLink }
|
||||
it { should contain_tag PageLink }
|
||||
it { should contain_tag NextLink }
|
||||
it { should_not contain_tag NextSpan }
|
||||
it { should contain_tag TruncatedSpan }
|
||||
end
|
||||
context 'seventh page(no truncation)' do
|
||||
subject { tags_with :num_pages => 10, :current_page => 7 }
|
||||
it { should contain_tag PrevLink }
|
||||
it { should_not contain_tag PrevSpan }
|
||||
it { should contain_tag CurrentPage }
|
||||
it { should contain_tag FirstPageLink }
|
||||
it { should contain_tag LastPageLink }
|
||||
it { should contain_tag PageLink }
|
||||
it { should contain_tag NextLink }
|
||||
it { should_not contain_tag NextSpan }
|
||||
it { should_not contain_tag TruncatedSpan }
|
||||
end
|
||||
|
||||
context 'last page' do
|
||||
subject { tags_with :num_pages => 10, :current_page => 10 }
|
||||
it { should contain_tag PrevLink }
|
||||
it { should_not contain_tag PrevSpan }
|
||||
it { should contain_tag CurrentPage }
|
||||
it { should contain_tag FirstPageLink }
|
||||
it { should_not contain_tag LastPageLink }
|
||||
it { should contain_tag PageLink }
|
||||
it { should_not contain_tag NextLink }
|
||||
it { should contain_tag NextSpan }
|
||||
it { should contain_tag TruncatedSpan }
|
||||
context 'eighth page' do
|
||||
subject { tags_with :num_pages => 10, :current_page => 8 }
|
||||
it { should contain_tag PrevLink }
|
||||
it { should_not contain_tag PrevSpan }
|
||||
it { should contain_tag CurrentPage }
|
||||
it { should contain_tag FirstPageLink }
|
||||
it { should contain_tag LastPageLink }
|
||||
it { should contain_tag PageLink }
|
||||
it { should contain_tag NextLink }
|
||||
it { should_not contain_tag NextSpan }
|
||||
it { should contain_tag TruncatedSpan }
|
||||
end
|
||||
|
||||
context 'last page' do
|
||||
subject { tags_with :num_pages => 10, :current_page => 10 }
|
||||
it { should contain_tag PrevLink }
|
||||
it { should_not contain_tag PrevSpan }
|
||||
it { should contain_tag CurrentPage }
|
||||
it { should contain_tag FirstPageLink }
|
||||
it { should_not contain_tag LastPageLink }
|
||||
it { should contain_tag PageLink }
|
||||
it { should_not contain_tag NextLink }
|
||||
it { should contain_tag NextSpan }
|
||||
it { should contain_tag TruncatedSpan }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue