diff options
author | Emilio Tagua <miloops@gmail.com> | 2010-09-15 11:22:24 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2010-11-19 19:07:43 -0300 |
commit | f3adddb966f3c93de4992b42cf554e3ef2a3acf1 (patch) | |
tree | 83d31288faa055e1dfc9a7474a9c7d52c9374e66 /activerecord/test/cases | |
parent | e83f5a0ae97889dddfd0956081b0f4582594cda9 (diff) | |
download | rails-f3adddb966f3c93de4992b42cf554e3ef2a3acf1.tar.gz rails-f3adddb966f3c93de4992b42cf554e3ef2a3acf1.tar.bz2 rails-f3adddb966f3c93de4992b42cf554e3ef2a3acf1.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')
-rw-r--r-- | activerecord/test/cases/identity_map_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
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 |