mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
A test for AR::Base.inherited
Ensure that Kaminari does not conflict with other gems that extend the inherited hook
This commit is contained in:
parent
ffbc900e6b
commit
6fed8cd8fd
2 changed files with 27 additions and 2 deletions
|
@ -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
|
||||
|
|
9
spec/models/active_record/inherited_spec.rb
Normal file
9
spec/models/active_record/inherited_spec.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue