Sha256: 7c17c303d5b67150866c0ce715e8870f4f5a692494498ea4685241ba52edba66

Contents?: true

Size: 870 Bytes

Versions: 2

Compression:

Stored size: 870 Bytes

Contents

require File.join(File.dirname(__FILE__), '..', 'CONFIG.rb')

require 'test/unit'

require 'og'
require 'glue/optimistic_locking'

$og = Og.setup(
  :store => 'psql',
  :name => 'test',
  :user => 'postgres',
  :password => 'navelrulez',
  :destroy => true
)

class TC_OgLocking < Test::Unit::TestCase # :nodoc: all
  include Og
  
  class Article
    property :body, String
    include Og::Locking
    
    def initialize(body)
      @body = body
    end
  end
    
  def test_all
    $og.manage_classes    
    
    Article.create('test')

    a = Article[1]
    
    b = Article[1]
    
    a.body = 'Changed'
    assert_nothing_raised do
      a.save
    end
    
    b.body = 'Ooops'
    assert_raise(Og::StaleObjectError) do
      b.update
    end
    
    c = Article[1]
    a.body = 'Changed again'
    assert_nothing_raised do
      a.update
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
og-0.25.0 test/og/mixin/tc_optimistic_locking.rb
og-0.26.0 test/og/mixin/tc_optimistic_locking.rb