diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2017-08-23 16:08:34 -0400 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2017-10-23 12:50:46 -0400 |
commit | 63cf15877bae859ff7b4ebaf05186f3ca79c1863 (patch) | |
tree | a44d48a738159d2db928fc5aa68bd24b85fc8679 /activerecord/test/cases | |
parent | e65aff70696be52b46ebe57207ebd8bb2cfcdbb6 (diff) | |
download | rails-63cf15877bae859ff7b4ebaf05186f3ca79c1863.tar.gz rails-63cf15877bae859ff7b4ebaf05186f3ca79c1863.tar.bz2 rails-63cf15877bae859ff7b4ebaf05186f3ca79c1863.zip |
Rase when calling `lock!` in a dirty record
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/locking_test.rb | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/activerecord/test/cases/locking_test.rb b/activerecord/test/cases/locking_test.rb index 743680ba92..6791d50940 100644 --- a/activerecord/test/cases/locking_test.rb +++ b/activerecord/test/cases/locking_test.rb @@ -565,18 +565,18 @@ unless in_memory_db? end end - # Locking a record reloads it. - def test_sane_lock_method + def test_lock_does_not_raise_when_the_object_is_not_dirty + person = Person.find 1 assert_nothing_raised do - Person.transaction do - person = Person.find 1 - old, person.first_name = person.first_name, "fooman" - # Locking a dirty record is deprecated - assert_deprecated do - person.lock! - end - assert_equal old, person.first_name - end + person.lock! + end + end + + def test_lock_raises_when_the_record_is_dirty + person = Person.find 1 + person.first_name = "fooman" + assert_raises(RuntimeError) do + person.lock! end end |