aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorMehmet Emin İNAÇ <mehmetemininac@gmail.com>2015-04-16 17:40:52 +0300
committerMehmet Emin İNAÇ <mehmetemininac@gmail.com>2015-04-19 23:50:13 +0300
commit5e8d96c5234d3f378f9048bf6c0077bb1139ce9a (patch)
treec907b45668c6c48d8dd9c305412e3a1434df0550 /activerecord/test
parentc8bab30ce5a7a40be7a3c7c4271e8ae6d2b303bb (diff)
downloadrails-5e8d96c5234d3f378f9048bf6c0077bb1139ce9a.tar.gz
rails-5e8d96c5234d3f378f9048bf6c0077bb1139ce9a.tar.bz2
rails-5e8d96c5234d3f378f9048bf6c0077bb1139ce9a.zip
Raise StaleObjectError if touched object is stale and locking is enabled
Fixes #19776 change test variable names and use more verbose on method less verbose use _read_attribute instead of send
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/locking_test.rb10
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)