diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-06-20 01:58:36 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-06-20 01:58:36 +0000 |
commit | 722e0b6a8bb62226437e466b5a98356d026b05f5 (patch) | |
tree | 63aebf36e9d2dcc63f35210b764b1af061178073 /activerecord/test | |
parent | e4254939aa8abb7a18f65e95cafaa2f37cbfa754 (diff) | |
download | rails-722e0b6a8bb62226437e466b5a98356d026b05f5.tar.gz rails-722e0b6a8bb62226437e466b5a98356d026b05f5.tar.bz2 rails-722e0b6a8bb62226437e466b5a98356d026b05f5.zip |
r4664@asus: jeremy | 2006-06-19 18:55:36 -0700
Use the #lock method to obtain a row lock on a single record. Simply reloads the record with :lock => true.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4462 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/locking_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/locking_test.rb b/activerecord/test/locking_test.rb index bacc7b8ae0..1923ff590d 100644 --- a/activerecord/test/locking_test.rb +++ b/activerecord/test/locking_test.rb @@ -82,6 +82,18 @@ class PessimisticLockingTest < Test::Unit::TestCase end end + # Locking a record reloads it. + def test_sane_lock_method + assert_nothing_raised do + Person.transaction do + person = Person.find 1 + old, person.first_name = person.first_name, 'fooman' + person.lock! + assert_equal old, person.first_name + end + end + end + if current_adapter?(:PostgreSQLAdapter) def test_no_locks_no_wait first, second = duel { Person.find 1 } |