tests for AR group query
This commit is contained in:
parent
062c60344b
commit
d0b28fcc5f
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue