Skip to content

Commit d2fcc26

Browse files
authored
MONGOID-5790/MONGOID-5791 Fix error caused by loading a referenced class prematurely (#5839)
It's such a pleasure to delete dead code...and even more so when the dead-code is responsible for a bug, simply by existing!
1 parent 971cf67 commit d2fcc26

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

lib/mongoid/touchable.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,6 @@ def touch_callback_statuses
212212
#
213213
# @return [ Symbol ] The method name.
214214
def define_relation_touch_method(name, association)
215-
relation_classes = if association.polymorphic?
216-
association.send(:inverse_association_classes)
217-
else
218-
[ association.relation_class ]
219-
end
220-
221215
method_name = "touch_#{name}_after_create_or_destroy"
222216
association.inverse_class.class_eval do
223217
define_method(method_name) do

spec/mongoid/association_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@
1515
)
1616
end
1717

18+
context "when class_name references an unknown class" do
19+
context "when loading" do
20+
it "does not raise an exception" do
21+
expect do
22+
class AssocationSpecModel
23+
include Mongoid::Document
24+
25+
embedded_in :parent, class_name: 'SomethingBogusThatDoesNotExistYet'
26+
end
27+
end.not_to raise_exception
28+
end
29+
end
30+
end
31+
1832
describe "#embedded?" do
1933

2034
let(:person) do

0 commit comments

Comments
 (0)