Sha256: 4b2e6b5424ba74cb3c57e77e875f1b8937926bfdff3ebd03648f2cae9253e163

Contents?: true

Size: 925 Bytes

Versions: 4

Compression:

Stored size: 925 Bytes

Contents

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

require 'rubygems'
require 'facets'
require 'test/unit'

require 'og'
require 'glue/optimistic_locking'

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

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

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

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
og-0.28.0 test/og/mixin/tc_optimistic_locking.rb
og-0.29.0 test/og/mixin/tc_optimistic_locking.rb
og-0.30.0 test/og/mixin/tc_optimistic_locking.rb
og-0.31.0 test/og/mixin/tc_optimistic_locking.rb