Skip to content

Commit

Permalink
spec for model inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
amatsuda committed Aug 21, 2011
1 parent 6896422 commit f534a63
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions spec/fake_app.rb
Expand Up @@ -53,6 +53,9 @@ class Book < ActiveRecord::Base
has_many :authors, :through => :authorships, :source => :user
has_many :readers, :through => :readerships, :source => :user
end
# a model that is a descendant of AR::Base but doesn't directly inherit AR::Base
class Admin < User
end

# controllers
class ApplicationController < ActionController::Base; end
Expand Down
11 changes: 6 additions & 5 deletions spec/models/scopes_spec.rb
Expand Up @@ -10,12 +10,13 @@
end

describe Kaminari::ActiveRecordExtension do
[User, GemDefinedModel].each do |model_class|
context "for #{model_class}" do
before :all do
1.upto(100) {|i| model_class.create! :name => "user#{'%03d' % i}", :age => (i / 10)}
end
before :all do
1.upto(100) {|i| User.create! :name => "user#{'%03d' % i}", :age => (i / 10)}
1.upto(100) {|i| GemDefinedModel.create! :name => "user#{'%03d' % i}", :age => (i / 10)}
end

[User, Admin, GemDefinedModel].each do |model_class|
context "for #{model_class}" do
describe '#page' do
context 'page 1' do
subject { model_class.page 1 }
Expand Down

0 comments on commit f534a63

Please sign in to comment.