On 10/17/05, Paul Chin <paulchin-0SqPFV7GnR3FK4RKhr3rmg@public.gmane.org>
wrote:> Hi all I wonder anyone can help me with this.
>
> I have implemented acts_as_version and I have locked_version too, it seems
> that if I can only have either one working and not both.
>
> If I have the locked_version field in my table first, locked_version will
> work by incrementing, but version field will always stay at 1. If I switch
> it arround, locked_version will always null.
>
> Question do I need locked_version as all if I have acts_as_version ? will
it
> implement optimistic lock ?
I''ll have to do some checking later on this. Optimistic locking did
cause me problems, but my unit test did seem to pass. I basically
have to turn optimistic locking off temporarily for rollbacks. Here''s
my simple test case though:
def test_lock_version_works_with_versioning
p = locked_pages(:thinking)
p2 = LockedPage.find(p.id)
p.title = ''fresh title''
p.save
assert_equal 2, p.versions.size # limit!
assert_raises(ActiveRecord::StaleObjectError) do
p2.title = ''stale title''
p2.save
end
end
Is there something I should add to the test case?
--
rick
http://techno-weenie.net