blob: 2b77a299071926060f6012ebac0d89ce68e05174 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
require 'abstract_unit'
require 'fixtures/person'
class LockingTest < Test::Unit::TestCase
def setup
@people = create_fixtures('people')
end
def test_lock_existing
p1 = Person.find(1)
p2 = Person.find(1)
p1.first_name = "Michael"
p1.save
assert_raises(ActiveRecord::StaleObjectError) {
p2.first_name = "should fail"
p2.save
}
end
def test_lock_new
p1 = Person.create({ "first_name"=>"anika"})
p2 = Person.find(p1.id)
assert_equal p1.id, p2.id
p1.first_name = "Anika"
p1.save
assert_raises(ActiveRecord::StaleObjectError) {
p2.first_name = "should fail"
p2.save
}
end
end
|