From 9abf606a79729833fd90f624ed580ad85f3ebadc Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Thu, 29 Dec 2016 16:17:01 +0900 Subject: Should not update children when the parent creation with no reason This issue was introduced with d849f42 to solve #19782. However, we can solve #19782 without causing the issue. It is enough to save only when necessary. Fixes #27338. --- activerecord/test/cases/autosave_association_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb index eb80ae4f7c..6d31b7a091 100644 --- a/activerecord/test/cases/autosave_association_test.rb +++ b/activerecord/test/cases/autosave_association_test.rb @@ -1391,6 +1391,14 @@ module AutosaveAssociationOnACollectionAssociationTests assert_equal "Squawky", parrot.reload.name end + def test_should_not_update_children_when_parent_creation_with_no_reason + parrot = Parrot.create!(name: "Polly") + assert_equal 0, parrot.updated_count + + Pirate.create!(parrot_ids: [parrot.id], catchphrase: "Arrrr") + assert_equal 0, parrot.reload.updated_count + end + def test_should_automatically_validate_the_associated_models @pirate.send(@association_name).each { |child| child.name = "" } -- cgit v1.2.3