mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
Merge branch 'master' of https://github.com/tyok/kaminari into tyok-master
This commit is contained in:
commit
d3e2f4e552
2 changed files with 23 additions and 1 deletions
|
@ -5,7 +5,9 @@ module Kaminari
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
delegate :page, :per, :num_pages, :current_page, :limit_value, :offset_value, :pagination_count, :to => '@klass'
|
||||
def page(*args)
|
||||
self.klass.page(*args).criteria.merge(self)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ describe Kaminari::MongoidExtension do
|
|||
before :all do
|
||||
class Developer
|
||||
include ::Mongoid::Document
|
||||
field :value, :type => Integer
|
||||
end
|
||||
end
|
||||
before do
|
||||
|
@ -39,6 +40,25 @@ describe Kaminari::MongoidExtension do
|
|||
its(:num_pages) { should == 12 }
|
||||
it { should skip 0 }
|
||||
end
|
||||
|
||||
context 'with criteria before' do
|
||||
subject { Developer.where(:value => 1).page 2 }
|
||||
its(:selector) { should == {:value => 1} }
|
||||
its(:current_page) { should == 2 }
|
||||
its(:limit_value) { should == 25 }
|
||||
its(:num_pages) { should == 12 }
|
||||
it { should skip 25 }
|
||||
end
|
||||
|
||||
context 'with criteria after' do
|
||||
subject { Developer.page(2).where(:value => 1) }
|
||||
its(:selector) { should == {:value => 1} }
|
||||
its(:current_page) { should == 2 }
|
||||
its(:limit_value) { should == 25 }
|
||||
its(:num_pages) { should == 12 }
|
||||
it { should skip 25 }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe '#per' do
|
||||
|
|
Loading…
Reference in a new issue