1
0
Fork 0
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:
Akira Matsuda 2011-02-24 21:55:18 +09:00
commit d3e2f4e552
2 changed files with 23 additions and 1 deletions

View file

@ -5,7 +5,9 @@ module Kaminari
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do 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
end end

View file

@ -6,6 +6,7 @@ describe Kaminari::MongoidExtension do
before :all do before :all do
class Developer class Developer
include ::Mongoid::Document include ::Mongoid::Document
field :value, :type => Integer
end end
end end
before do before do
@ -39,6 +40,25 @@ describe Kaminari::MongoidExtension do
its(:num_pages) { should == 12 } its(:num_pages) { should == 12 }
it { should skip 0 } it { should skip 0 }
end 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 end
describe '#per' do describe '#per' do