diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2015-01-07 15:56:50 -0800 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2015-01-07 15:56:50 -0800 |
commit | f6b21d48ef15d4f39a530653c2ce7d0cfb458b46 (patch) | |
tree | 877090d36f381f3c5237d281e362a96c2a05bc92 /activerecord/test/cases | |
parent | af2e0fec0971e1a9d76a5cd87c9324c3d92e5ec1 (diff) | |
parent | fb71fa695d214eb5aaa6f95440347e3a08f03b38 (diff) | |
download | rails-f6b21d48ef15d4f39a530653c2ce7d0cfb458b46.tar.gz rails-f6b21d48ef15d4f39a530653c2ce7d0cfb458b46.tar.bz2 rails-f6b21d48ef15d4f39a530653c2ce7d0cfb458b46.zip |
Merge pull request #16640 from mfazekas/fix_loop_in_changed_for_autosave
Fix potenital infinite recursion in changed_for_autosave?
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/autosave_association_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb index 04d5a2869c..52765881d0 100644 --- a/activerecord/test/cases/autosave_association_test.rb +++ b/activerecord/test/cases/autosave_association_test.rb @@ -1030,6 +1030,16 @@ class TestAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCase assert_equal 'The Vile Insanity', @pirate.reload.ship.name end + def test_changed_for_autosave_should_handle_cycles + @ship.pirate = @pirate + assert_queries(0) { @ship.save! } + + @parrot = @pirate.parrots.create(name: "some_name") + @parrot.name="changed_name" + assert_queries(1) { @ship.save! } + assert_queries(0) { @ship.save! } + end + def test_should_automatically_save_bang_the_associated_model @pirate.ship.name = 'The Vile Insanity' @pirate.save! |