diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-04-19 16:54:39 -0400 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-04-19 16:54:39 -0400 |
commit | 9721b45b40c045a132b7177f0e86b0f5d567a2df (patch) | |
tree | 82ab33b69395bc189a4032ffd0bdba3833c958c9 /activerecord/test | |
parent | 8f3584ab30cb1d2a23a2c59cd0c2e467facd390d (diff) | |
parent | 5e8d96c5234d3f378f9048bf6c0077bb1139ce9a (diff) | |
download | rails-9721b45b40c045a132b7177f0e86b0f5d567a2df.tar.gz rails-9721b45b40c045a132b7177f0e86b0f5d567a2df.tar.bz2 rails-9721b45b40c045a132b7177f0e86b0f5d567a2df.zip |
Merge pull request #19783 from vngrs/raise_error_on_touch_if_object_is_stale
Raise StaleObjectError if touched object is stale and locking is enabled
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/locking_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/locking_test.rb b/activerecord/test/cases/locking_test.rb index 9e4998a946..dbdcc84b7d 100644 --- a/activerecord/test/cases/locking_test.rb +++ b/activerecord/test/cases/locking_test.rb @@ -177,6 +177,16 @@ class OptimisticLockingTest < ActiveRecord::TestCase assert_equal 1, p1.lock_version end + def test_touch_stale_object + person = Person.create!(first_name: 'Mehmet Emin') + stale_person = Person.find(person.id) + person.update_attribute(:gender, 'M') + + assert_raises(ActiveRecord::StaleObjectError) do + stale_person.touch + end + end + def test_lock_column_name_existing t1 = LegacyThing.find(1) t2 = LegacyThing.find(1) |