From e83f5a0ae97889dddfd0956081b0f4582594cda9 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Wed, 15 Sep 2010 11:18:34 -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 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (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 c51bdf5f69..d4be698082 100644 --- a/activerecord/test/cases/identity_map_test.rb +++ b/activerecord/test/cases/identity_map_test.rb @@ -30,7 +30,7 @@ class IdentityMapTest < ActiveRecord::TestCase end def test_find_id_without_identity_map - IdentityMap.without do + ActiveRecord::IdentityMap.without do assert_not_same(Client.find(3), Client.find(3)) end end @@ -247,4 +247,18 @@ class IdentityMapTest < ActiveRecord::TestCase Developer.joins(', projects').each { |d| assert d.readonly? } Developer.joins(', projects').readonly(false).each { |d| assert d.readonly? } end + + def test_reload_object_if_save_failed + developer = Developer.first + developer.salary = 0 + + assert !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