diff --git a/spec/lib/amoeba/config/has_many_spec.rb b/spec/lib/amoeba/config/has_many_spec.rb index 7e7ef3f..8203a14 100644 --- a/spec/lib/amoeba/config/has_many_spec.rb +++ b/spec/lib/amoeba/config/has_many_spec.rb @@ -18,6 +18,7 @@ t.boolean :extra end + reset_model_cache stub_const 'Parent', Class.new(ActiveRecord::Base) stub_const 'Child', Class.new(ActiveRecord::Base) Parent.class_eval <<~CONFIG, __FILE__, __LINE__ + 1 @@ -127,6 +128,7 @@ t.references :child end + reset_model_cache stub_const 'Parent', Class.new(ActiveRecord::Base) stub_const 'Child', Class.new(ActiveRecord::Base) stub_const 'ParentChild', Class.new(ActiveRecord::Base) diff --git a/spec/lib/amoeba/config/has_one_spec.rb b/spec/lib/amoeba/config/has_one_spec.rb index 471ef41..7c0e0d6 100644 --- a/spec/lib/amoeba/config/has_one_spec.rb +++ b/spec/lib/amoeba/config/has_one_spec.rb @@ -31,6 +31,7 @@ t.string :name end + reset_model_cache stub_const 'Parent', Class.new(ActiveRecord::Base) stub_const 'Child', Class.new(ActiveRecord::Base) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8e3df44..cb48054 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -18,6 +18,7 @@ require 'active_record' require 'amoeba' +require 'support/helpers' adapter = if defined?(JRuby) require 'activerecord-jdbcsqlite3-adapter' diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb new file mode 100644 index 0000000..05415df --- /dev/null +++ b/spec/support/helpers.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +def reset_model_cache + ActiveSupport::Dependencies::Reference.clear! if ActiveSupport::VERSION::MAJOR < 7 +end