diff options
author | José Valim <jose.valim@gmail.com> | 2011-10-14 09:42:03 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-10-14 09:42:03 -0700 |
commit | 521a089166a17d447c3b3b32ff7f9394774ca895 (patch) | |
tree | 4de9603d0f57beb70d7374bf46b073e3995731d9 /activerecord/test | |
parent | 401d00d296c0c4dafd0e1103051f6adf0ae56fc5 (diff) | |
parent | c6f0461e898601578fa8160608d19fec319067fa (diff) | |
download | rails-521a089166a17d447c3b3b32ff7f9394774ca895.tar.gz rails-521a089166a17d447c3b3b32ff7f9394774ca895.tar.bz2 rails-521a089166a17d447c3b3b32ff7f9394774ca895.zip |
Merge pull request #3331 from fabrik42/master
Include affected record when raising an ActiveRecord::StaleObjectError
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/locking_test.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/activerecord/test/cases/locking_test.rb b/activerecord/test/cases/locking_test.rb index 61baa55027..e9bd7f07b6 100644 --- a/activerecord/test/cases/locking_test.rb +++ b/activerecord/test/cases/locking_test.rb @@ -125,6 +125,24 @@ class OptimisticLockingTest < ActiveRecord::TestCase assert_raise(ActiveRecord::StaleObjectError) { p2.save! } end + def test_lock_exception_record + p1 = Person.new(:first_name => 'mira') + assert_equal 0, p1.lock_version + + p1.first_name = 'mira2' + p1.save! + p2 = Person.find(p1.id) + assert_equal 0, p1.lock_version + assert_equal 0, p2.lock_version + + p1.first_name = 'mira3' + p1.save! + + p2.first_name = 'sue' + error = assert_raise(ActiveRecord::StaleObjectError) { p2.save! } + assert_equal(error.record.object_id, p2.object_id) + end + def test_lock_new_with_nil p1 = Person.new(:first_name => 'anika') p1.save! @@ -141,7 +159,6 @@ class OptimisticLockingTest < ActiveRecord::TestCase assert_equal 1, p1.lock_version end - def test_lock_column_name_existing t1 = LegacyThing.find(1) t2 = LegacyThing.find(1) |