提交 372e8096 编写于 作者: P Paul Nikitochkin

Do not re-save destroyed association on saving parent object

Closes #11450
上级 0b61cc73
......@@ -343,6 +343,7 @@ def save_collection_association(reflection)
end
records.each do |record|
next if record.destroyed?
saved = true
......
......@@ -705,6 +705,13 @@ def test_should_destroy_has_many_as_part_of_the_save_transaction_if_they_were_ma
ids.each { |id| assert_nil klass.find_by_id(id) }
end
def test_should_not_resave_destroyed_association
@pirate.birds.create!(name: :parrot)
@pirate.birds.first.destroy
@pirate.save!
assert @pirate.reload.birds.empty?
end
def test_should_skip_validation_on_has_many_if_marked_for_destruction
2.times { |i| @pirate.birds.create!(:name => "birds_#{i}") }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册