diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-04-10 13:18:34 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-10 13:18:34 +0900 |
commit | eb3740dcb0c2cc648aea13116628d257bc7ebc3b (patch) | |
tree | 5bb6140ee50973889228418c66d4bd0e04cfea88 /activerecord | |
parent | 36ce219ca08f7768a402f846d202f3c5b370718e (diff) | |
parent | 80a09caedc6fa67f95e78e45e7eb954f6b647b2c (diff) | |
download | rails-eb3740dcb0c2cc648aea13116628d257bc7ebc3b.tar.gz rails-eb3740dcb0c2cc648aea13116628d257bc7ebc3b.tar.bz2 rails-eb3740dcb0c2cc648aea13116628d257bc7ebc3b.zip |
Merge pull request #32498 from eugeneius/mutation_tracker_merge_changes
Prevent changes_to_save from mutating attributes
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/dirty_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/dirty_test.rb b/activerecord/test/cases/dirty_test.rb index 2f1434b2bc..5c7f70b7a0 100644 --- a/activerecord/test/cases/dirty_test.rb +++ b/activerecord/test/cases/dirty_test.rb @@ -473,6 +473,14 @@ class DirtyTest < ActiveRecord::TestCase end end + def test_changes_to_save_should_not_mutate_array_of_hashes + topic = Topic.new(author_name: "Bill", content: [{ a: "a" }]) + + topic.changes_to_save + + assert_equal [{ a: "a" }], topic.content + end + def test_previous_changes # original values should be in previous_changes pirate = Pirate.new |