From f3adddb966f3c93de4992b42cf554e3ef2a3acf1 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Wed, 15 Sep 2010 11:22:24 -0300 Subject: Remove objects from identity map if save! failed, otherwise finding again the same record will have invalid attributes. --- activerecord/test/cases/identity_map_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'activerecord/test/cases/identity_map_test.rb') diff --git a/activerecord/test/cases/identity_map_test.rb b/activerecord/test/cases/identity_map_test.rb index d4be698082..1683bd28c3 100644 --- a/activerecord/test/cases/identity_map_test.rb +++ b/activerecord/test/cases/identity_map_test.rb @@ -261,4 +261,17 @@ class IdentityMapTest < ActiveRecord::TestCase assert_not_equal developer.salary, same_developer.salary end + def test_reload_object_if_forced_save_failed + developer = Developer.first + developer.salary = 0 + + assert_raise(ActiveRecord::RecordInvalid) { developer.save! } + + same_developer = Developer.first + + assert_not_same developer, same_developer + assert_not_equal 0, same_developer.salary + assert_not_equal developer.salary, same_developer.salary + end + end -- cgit v1.2.3