spec/mongoid/reloadable_spec.rb in mongoid-8.0.4 vs spec/mongoid/reloadable_spec.rb in mongoid-8.0.5

- old
+ new

@@ -388,9 +388,33 @@ expect(building.contractors).to eq([]) end end end + context 'when embeds_many is modified' do + let(:contractor1) { Contractor.new(name: 'b') } + let(:contractor2) { Contractor.new(name: 'c') } + + let(:building) do + Building.create!(contractors: [ contractor1 ]) + end + + let(:more_contractors) { building.contractors + [ contractor2 ] } + + let(:modified_building) do + building.tap do + building.assign_attributes contractors: more_contractors + end + end + + let(:reloaded_building) { modified_building.reload } + + it 'resets delayed_atomic_sets' do + expect(modified_building.delayed_atomic_sets).not_to be_empty + expect(reloaded_building.delayed_atomic_sets).to be_empty + end + end + context "when embedded document is nil" do let(:palette) do Palette.new end