mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
Merge branch 'pass-test-suite' of github.com:wbyoung/kaminari into wbyoung-pass-test-suite
Conflicts: spec/models/active_record/active_record_relation_methods_spec.rb
This commit is contained in:
commit
be7ba2d3a8
4 changed files with 6 additions and 6 deletions
|
@ -5,8 +5,10 @@ module Kaminari
|
||||||
module Paginatable
|
module Paginatable
|
||||||
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
||||||
def #{Kaminari.config.page_method_name}(num = 1)
|
def #{Kaminari.config.page_method_name}(num = 1)
|
||||||
|
model = self
|
||||||
|
model = self.model if self.is_a? DataMapper::Collection
|
||||||
num = [num.to_i, 1].max - 1
|
num = [num.to_i, 1].max - 1
|
||||||
all(:limit => default_per_page, :offset => default_per_page * num).extend Paginating
|
all(:limit => model.default_per_page, :offset => model.default_per_page * num).extend Paginating
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,7 +38,7 @@ if defined? ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when total_count receives options" do
|
context "when total_count receives options" do
|
||||||
it "should return a distinct total count for rails ~> 4.0.0" do
|
it "should return a distinct total count for rails < 4.1" do
|
||||||
if ActiveRecord::VERSION::STRING < "4.1.0"
|
if ActiveRecord::VERSION::STRING < "4.1.0"
|
||||||
User.page(1).total_count(:name, :distinct => true).should == 4
|
User.page(1).total_count(:name, :distinct => true).should == 4
|
||||||
end
|
end
|
||||||
|
@ -52,7 +52,7 @@ if defined? ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when count receives options" do
|
context "when count receives options" do
|
||||||
it "should return a distinct set by column for rails ~> 4.0.0" do
|
it "should return a distinct set by column for rails < 4.1" do
|
||||||
if ActiveRecord::VERSION::STRING < "4.1.0"
|
if ActiveRecord::VERSION::STRING < "4.1.0"
|
||||||
User.page(1).count(:name, :distinct => true).should == 4
|
User.page(1).count(:name, :distinct => true).should == 4
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,13 +17,13 @@ if defined? DataMapper
|
||||||
|
|
||||||
describe 'Model' do
|
describe 'Model' do
|
||||||
subject { User }
|
subject { User }
|
||||||
its(:current_page) { should == 1 }
|
|
||||||
it { User.all.count.should == 100 }
|
it { User.all.count.should == 100 }
|
||||||
it { User.page(1).length.should == 25 }
|
it { User.page(1).length.should == 25 }
|
||||||
it {
|
it {
|
||||||
User.paginates_per(5)
|
User.paginates_per(5)
|
||||||
User.page(1).length.should == 5
|
User.page(1).length.should == 5
|
||||||
User.all.page(1).length.should == 5
|
User.all.page(1).length.should == 5
|
||||||
|
User.paginates_per(nil) # reset to default
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ DatabaseCleaner[:mongo_mapper].strategy = :truncation if defined? MongoMapper
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.before :suite do
|
config.before :suite do
|
||||||
#DatabaseCleaner.clean_with :truncation
|
|
||||||
|
|
||||||
DatabaseCleaner.clean_with :truncation if defined? ActiveRecord
|
DatabaseCleaner.clean_with :truncation if defined? ActiveRecord
|
||||||
DatabaseCleaner.clean_with :truncation if defined? DataMapper
|
DatabaseCleaner.clean_with :truncation if defined? DataMapper
|
||||||
DatabaseCleaner.clean_with :truncation if defined? Mongoid
|
DatabaseCleaner.clean_with :truncation if defined? Mongoid
|
||||||
|
|
Loading…
Reference in a new issue