diff options
Diffstat (limited to 'activerecord/test/cases/locking_test.rb')
-rw-r--r-- | activerecord/test/cases/locking_test.rb | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/activerecord/test/cases/locking_test.rb b/activerecord/test/cases/locking_test.rb index 077cac7747..e177235591 100644 --- a/activerecord/test/cases/locking_test.rb +++ b/activerecord/test/cases/locking_test.rb @@ -35,7 +35,25 @@ class OptimisticLockingTest < ActiveRecord::TestCase assert_equal 0, p2.lock_version p2.first_name = 'sue' - assert_raises(ActiveRecord::StaleObjectError) { p2.save! } + assert_raise(ActiveRecord::StaleObjectError) { p2.save! } + end + + def test_lock_destroy + p1 = Person.find(1) + p2 = Person.find(1) + assert_equal 0, p1.lock_version + assert_equal 0, p2.lock_version + + p1.first_name = 'stu' + p1.save! + assert_equal 1, p1.lock_version + assert_equal 0, p2.lock_version + + assert_raises(ActiveRecord::StaleObjectError) { p2.destroy } + + assert p1.destroy + assert_equal true, p1.frozen? + assert_raises(ActiveRecord::RecordNotFound) { Person.find(1) } end def test_lock_repeating @@ -50,9 +68,9 @@ class OptimisticLockingTest < ActiveRecord::TestCase assert_equal 0, p2.lock_version p2.first_name = 'sue' - assert_raises(ActiveRecord::StaleObjectError) { p2.save! } + assert_raise(ActiveRecord::StaleObjectError) { p2.save! } p2.first_name = 'sue2' - assert_raises(ActiveRecord::StaleObjectError) { p2.save! } + assert_raise(ActiveRecord::StaleObjectError) { p2.save! } end def test_lock_new @@ -71,7 +89,7 @@ class OptimisticLockingTest < ActiveRecord::TestCase assert_equal 0, p2.lock_version p2.first_name = 'sue' - assert_raises(ActiveRecord::StaleObjectError) { p2.save! } + assert_raise(ActiveRecord::StaleObjectError) { p2.save! } end def test_lock_new_with_nil @@ -95,7 +113,7 @@ class OptimisticLockingTest < ActiveRecord::TestCase assert_equal 0, t2.version t2.tps_report_number = 800 - assert_raises(ActiveRecord::StaleObjectError) { t2.save! } + assert_raise(ActiveRecord::StaleObjectError) { t2.save! } end def test_lock_column_is_mass_assignable |