-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
It'll be easier to show with a failing test case this problem..
require "spec_helper" class ChildTestClass include Mongoid::Document embedded_in :parent_test_class, inverse_of: :child_test_one embedded_in :parent_test_class, inverse_of: :child_test_two field :value, type: String end class ParentTestClass include Mongoid::Document embeds_one :child_test_one, cascade_callbacks: true, class_name: "ChildTestClass" embeds_one :child_test_two, cascade_callbacks: true, class_name: "ChildTestClass" end describe "a bug with mutliple embedded documents of the same type but different name" do it "should set them correctly" do parent = ParentTestClass.new ct1 = ChildTestClass.new(value: "A") ct2 = ChildTestClass.new(value: "B") ct3 = ChildTestClass.new(value: "C") parent.child_test_one = ct1 parent.child_test_two = ct2 parent.save! parent.reload.child_test_one.value.should == "A" parent.reload.child_test_two.value.should == "B" parent.child_test_one = ct3 parent.save! parent.reload.child_test_two.value.should == "B" # this is now "C" parent.reload.child_test_one.value.should == "C" # this is now nil end end
This is failing on 3.1.0-stable branch
- is related to
-
MONGOID-3724 Unable to build embedded more than one embedded document of the same type
- Closed