aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2018-09-13 15:50:38 -0400
committerRafael Mendonça França <rafaelmfranca@gmail.com>2018-09-13 15:50:38 -0400
commit7454cbf7a15556f1d78e61c7d9d64c93cee79ad3 (patch)
treee3e82615457bb9db3dde40f0044ac0d47933c55d /activerecord/test/cases
parentf89e2c2cba429efd62e9d6e2c4c96afa205c5135 (diff)
parent35ee756a366d3ac80128a017cf8ba197a0fdd4a1 (diff)
downloadrails-7454cbf7a15556f1d78e61c7d9d64c93cee79ad3.tar.gz
rails-7454cbf7a15556f1d78e61c7d9d64c93cee79ad3.tar.bz2
rails-7454cbf7a15556f1d78e61c7d9d64c93cee79ad3.zip
Merge pull request #33378 from numbata/subclass-redefine-autosave-callbacks
Allow subclasses to redefine autosave callbacks for associated records
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/autosave_association_test.rb19
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 fa618735d7..db3a58eba9 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"
@@ -1787,3 +1788,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