Skip to content

Commit

Permalink
prev_page method doesn't not have to be too intelligent
Browse files Browse the repository at this point in the history
We mightn't like this behaiviour as it behaves differently from
Paginator::PageProxy.
  • Loading branch information
yuki24 committed Sep 14, 2014
1 parent adca9b2 commit d524896
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/kaminari/models/page_scope_methods.rb
Expand Up @@ -55,7 +55,7 @@ def next_page

# Previous page number in the collection
def prev_page
current_page - 1 unless first_page? || current_page > (total_pages + 1)
current_page - 1 unless first_page? || out_of_range?
end

# First page of the collection?
Expand Down
10 changes: 5 additions & 5 deletions spec/models/active_record/scopes_spec.rb
Expand Up @@ -200,13 +200,13 @@ class Comment < ActiveRecord::Base; end
its(:prev_page) { should be_nil }
end

context 'page 5' do
subject { model_class.page(5) }
its(:prev_page) { should == 4 }
context 'page 3' do
subject { model_class.page(3) }
its(:prev_page) { should == 2 }
end

context 'page 6' do
subject { model_class.page(6) }
context 'page 5' do
subject { model_class.page(5) }
its(:prev_page) { should be_nil }
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/models/array_spec.rb
Expand Up @@ -137,13 +137,13 @@
its(:prev_page) { should be_nil }
end

context 'page 5' do
subject { array.page 5 }
its(:prev_page) { should == 4 }
context 'page 3' do
subject { array.page 3 }
its(:prev_page) { should == 2 }
end

context 'page 6' do
subject { array.page 6 }
context 'page 5' do
subject { array.page 5 }
its(:prev_page) { should be_nil }
end
end
Expand Down

0 comments on commit d524896

Please sign in to comment.