Sha256: 46e567398405707d349d42288372304772d58b7a543960ce2226fb0ceec67639

Contents?: true

Size: 795 Bytes

Versions: 2

Compression:

Stored size: 795 Bytes

Contents

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

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

require 'og'
require 'glue/optimistic_locking'

class TC_OgLocking < Test::Unit::TestCase # :nodoc: all
  include Og
  
  class Article
    attr_accessor :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

2 entries across 2 versions & 1 rubygems

Version Path
og-0.41.0 test/glue/tc_optimistic_locking.rb
og-0.40.0 test/glue/tc_optimistic_locking.rb