aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/identity_map_test.rb
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2010-09-15 11:18:34 -0300
committerEmilio Tagua <miloops@gmail.com>2010-11-19 19:07:43 -0300
commite83f5a0ae97889dddfd0956081b0f4582594cda9 (patch)
tree261b3bb6f7bcafa2cd108a7105bd032b987b7108 /activerecord/test/cases/identity_map_test.rb
parenta9edd6cf932b299e28677cb1e0af397c533caffe (diff)
downloadrails-e83f5a0ae97889dddfd0956081b0f4582594cda9.tar.gz
rails-e83f5a0ae97889dddfd0956081b0f4582594cda9.tar.bz2
rails-e83f5a0ae97889dddfd0956081b0f4582594cda9.zip
Remove objects from identity map if save failed, otherwise finding again the same record will have invalid attributes.
Diffstat (limited to 'activerecord/test/cases/identity_map_test.rb')
-rw-r--r--activerecord/test/cases/identity_map_test.rb16
1 files changed, 15 insertions, 1 deletions
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