1
0
Fork 0
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:
Akira Matsuda 2013-11-10 02:55:05 +09:00
commit be7ba2d3a8
4 changed files with 6 additions and 6 deletions

View file

@ -5,8 +5,10 @@ module Kaminari
module Paginatable
class_eval <<-RUBY, __FILE__, __LINE__ + 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
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
RUBY
end

View file

@ -38,7 +38,7 @@ if defined? ActiveRecord
end
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"
User.page(1).total_count(:name, :distinct => true).should == 4
end
@ -52,7 +52,7 @@ if defined? ActiveRecord
end
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"
User.page(1).count(:name, :distinct => true).should == 4
end

View file

@ -17,13 +17,13 @@ if defined? DataMapper
describe 'Model' do
subject { User }
its(:current_page) { should == 1 }
it { User.all.count.should == 100 }
it { User.page(1).length.should == 25 }
it {
User.paginates_per(5)
User.page(1).length.should == 5
User.all.page(1).length.should == 5
User.paginates_per(nil) # reset to default
}
end

View file

@ -5,8 +5,6 @@ DatabaseCleaner[:mongo_mapper].strategy = :truncation if defined? MongoMapper
RSpec.configure do |config|
config.before :suite do
#DatabaseCleaner.clean_with :truncation
DatabaseCleaner.clean_with :truncation if defined? ActiveRecord
DatabaseCleaner.clean_with :truncation if defined? DataMapper
DatabaseCleaner.clean_with :truncation if defined? Mongoid