Skip to content

Commit

Permalink
Merge branch 'pass-test-suite' of github.com:wbyoung/kaminari into wb…
Browse files Browse the repository at this point in the history
…young-pass-test-suite

Conflicts:
	spec/models/active_record/active_record_relation_methods_spec.rb
  • Loading branch information
amatsuda committed Nov 9, 2013
2 parents 04c0b26 + 06fec65 commit be7ba2d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 3 additions & 1 deletion lib/kaminari/models/data_mapper_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ module DataMapperExtension
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
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
Expand All @@ -52,7 +52,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion spec/models/data_mapper/data_mapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

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

Expand Down
2 changes: 0 additions & 2 deletions spec/support/database_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

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
Expand Down

0 comments on commit be7ba2d

Please sign in to comment.