Sha256: 039a6f7c90900f100f67c7e356b9f596cdc6936400c0b1a19dde4e4d8dba8d0d

Contents?: true

Size: 681 Bytes

Versions: 10

Compression:

Stored size: 681 Bytes

Contents

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
activerecord-1.10.0 test/locking_test.rb
activerecord-1.10.1 test/locking_test.rb
activerecord-1.4.0 test/locking_test.rb
activerecord-1.8.0 test/locking_test.rb
activerecord-1.6.0 test/locking_test.rb
activerecord-1.5.0 test/locking_test.rb
activerecord-1.5.1 test/locking_test.rb
activerecord-1.9.0 test/locking_test.rb
activerecord-1.7.0 test/locking_test.rb
activerecord-1.9.1 test/locking_test.rb