From ab3ad6a9ad119825636153cd521e25c280483340 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Fri, 11 May 2018 19:40:26 +0900 Subject: `becomes` should clear the mutation tracker which is created in `after_initialize` `becomes` creates new object and copies attributes from the receiver. If new object has mutation tracker which is created in `after_initialize`, it should be cleared since it is for discarded attributes. But if the receiver doesn't have mutation tracker yet, it will not be cleared properly. It should be cleared regardless of whether the receiver has mutation tracker or not. Fixes #32867. --- activerecord/test/models/topic.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/test/models') diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb index fa50eeb6a4..2e386d7669 100644 --- a/activerecord/test/models/topic.rb +++ b/activerecord/test/models/topic.rb @@ -97,7 +97,7 @@ class Topic < ActiveRecord::Base end def set_email_address - unless persisted? + unless persisted? || will_save_change_to_author_email_address? self.author_email_address = "test@test.com" end end -- cgit v1.2.3