diff options
author | Andrey Subbota <subbota@gmail.com> | 2018-07-17 12:55:30 +0300 |
---|---|---|
committer | Andrey Subbota <subbota@gmail.com> | 2018-07-27 00:38:21 +0300 |
commit | 35ee756a366d3ac80128a017cf8ba197a0fdd4a1 (patch) | |
tree | 85d116200b8d468622d5ce540e0aee0088eb64c5 /activerecord/test/cases/autosave_association_test.rb | |
parent | f0c917c7d491f4f7b142748375e1128d5579152a (diff) | |
download | rails-35ee756a366d3ac80128a017cf8ba197a0fdd4a1.tar.gz rails-35ee756a366d3ac80128a017cf8ba197a0fdd4a1.tar.bz2 rails-35ee756a366d3ac80128a017cf8ba197a0fdd4a1.zip |
Allow subclasses to redefine autosave callbacks for associated records
Diffstat (limited to 'activerecord/test/cases/autosave_association_test.rb')
-rw-r--r-- | activerecord/test/cases/autosave_association_test.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb index ade1f4b44d..6d0deb887b 100644 --- a/activerecord/test/cases/autosave_association_test.rb +++ b/activerecord/test/cases/autosave_association_test.rb @@ -14,6 +14,7 @@ require "models/line_item" require "models/order" require "models/parrot" require "models/pirate" +require "models/project" require "models/ship" require "models/ship_part" require "models/tag" @@ -1774,3 +1775,21 @@ class TestAutosaveAssociationOnAHasManyAssociationWithInverse < ActiveRecord::Te assert_equal 1, comment.post_comments_count end end + +class TestAutosaveAssociationOnAHasManyAssociationDefinedInSubclassWithAcceptsNestedAttributes < ActiveRecord::TestCase + def test_should_update_children_when_asssociation_redefined_in_subclass + agency = Agency.create!(name: "Agency") + valid_project = Project.create!(firm: agency, name: "Initial") + agency.update!( + "projects_attributes" => { + "0" => { + "name" => "Updated", + "id" => valid_project.id + } + } + ) + valid_project.reload + + assert_equal "Updated", valid_project.name + end +end |