diff --git a/spec/fake_app.rb b/spec/fake_app.rb index 9b40cfb..bf6fb1e 100644 --- a/spec/fake_app.rb +++ b/spec/fake_app.rb @@ -42,7 +42,7 @@ Object.const_set(:ApplicationHelper, Module.new) #migrations class CreateAllTables < ActiveRecord::Migration def self.up - create_table(:users) {|t| t.string :name } - create_table(:books) {|t| t.string :title } + create_table(:users) {|t| t.string :name; t.integer :age} + create_table(:books) {|t| t.string :title} end end diff --git a/spec/models/scopes_spec.rb b/spec/models/scopes_spec.rb index 728ff39..6bb40f2 100644 --- a/spec/models/scopes_spec.rb +++ b/spec/models/scopes_spec.rb @@ -3,7 +3,7 @@ require File.expand_path('../spec_helper', File.dirname(__FILE__)) describe Kaminari::ActiveRecordExtension do before :all do User.delete_all - 1.upto(100) {|i| User.create! :name => "user#{'%03d' % i}" } + 1.upto(100) {|i| User.create! :name => "user#{'%03d' % i}", :age => (i / 10)} end describe '#page' do @@ -94,4 +94,11 @@ describe Kaminari::ActiveRecordExtension do its(:current_page) { should == 2 } end end + + context 'chained with .group' do + subject { User.group('age').page(2).per 5 } + # 0..10 + its(:total_count) { should == 11 } + its(:num_pages) { should == 3 } + end end