Sha256: dce4d05ff0d8c4e0ea3f59a6abf02d7726a98d7cd92451f9e756192bad85bd91

Contents?: true

Size: 890 Bytes

Versions: 4

Compression:

Stored size: 890 Bytes

Contents

$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')

$DBG = true

require 'test/unit'

require 'og'
require 'og/mixin/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

4 entries across 4 versions & 1 rubygems

Version Path
og-0.21.0 test/og/mixin/tc_optimistic_locking.rb
og-0.21.2 test/og/mixin/tc_optimistic_locking.rb
og-0.22.0 test/og/mixin/tc_optimistic_locking.rb
og-0.23.0 test/og/mixin/tc_optimistic_locking.rb