From b574d283e57930105d505c2d34f6d4777dc21069 Mon Sep 17 00:00:00 2001 From: Vladimir Dementyev Date: Mon, 25 Mar 2019 18:50:27 -0400 Subject: Add saved changes helpers for store accessors --- activerecord/test/cases/store_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/store_test.rb b/activerecord/test/cases/store_test.rb index 1947868f05..91c0e959f4 100644 --- a/activerecord/test/cases/store_test.rb +++ b/activerecord/test/cases/store_test.rb @@ -136,6 +136,17 @@ class StoreTest < ActiveRecord::TestCase assert_equal ["Dallas", "Lena"], @john.partner_name_change end + test "saved changes tracking for accessors" do + @john.spouse[:name] = "Lena" + assert @john.partner_name_changed? + + @john.save! + assert_not @john.partner_name_change + assert @john.saved_change_to_partner_name? + assert_equal ["Dallas", "Lena"], @john.saved_change_to_partner_name + assert_equal "Dallas", @john.partner_name_before_last_save + end + test "object initialization with not nullable column" do assert_equal true, @john.remember_login end -- cgit v1.2.3