diff --git a/spec/fake_gem.rb b/spec/fake_gem.rb index fa3a1c2..78e9991 100644 --- a/spec/fake_gem.rb +++ b/spec/fake_gem.rb @@ -1,4 +1,20 @@ -# Simulate a gem providing a subclass of ActiveRecord::Base before the Railtie is loaded. +module Kaminari + module FakeGem + extend ActiveSupport::Concern -class GemDefinedModel < ActiveRecord::Base + module ClassMethods + def inherited(kls) + super + def kls.fake_gem_defined_method; end + end + end + end +end + +ActiveSupport.on_load :active_record do + ActiveRecord::Base.send :include, Kaminari::FakeGem + + # Simulate a gem providing a subclass of ActiveRecord::Base before the Railtie is loaded. + class GemDefinedModel < ActiveRecord::Base + end end diff --git a/spec/models/active_record/inherited_spec.rb b/spec/models/active_record/inherited_spec.rb new file mode 100644 index 0000000..c1c66f9 --- /dev/null +++ b/spec/models/active_record/inherited_spec.rb @@ -0,0 +1,9 @@ +require 'spec_helper' + +if defined? ActiveRecord + describe Kaminari::ActiveRecordModelExtension do + subject { Class.new(ActiveRecord::Base) } + it { should respond_to :page } + it { should respond_to :fake_gem_defined_method } + end +end