Sha256: 461375cc40c5aed9b6bd30c851e3a56c8e6df02d89ec1bb2295ecc8dc86fa5ab

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

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

$DBG = true

require 'test/unit'

require 'og'

$og1 = Og.setup(
  :destroy => true,
  :store => :mysql,
  :user => 'root',
  :password => 'navelrulez',
  :name => 'test'
)    

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

class TestMultiple < Test::Unit::TestCase # :nodoc: all
  include Og

  class User
    property :name, String, :uniq => true
    has_many Article
    
    def initialize(name)
      @name = name
    end
  end

  class Article
    property :title, String
    belongs_to User
    
    def initialize(title)
      @title = title
    end
  end
  
  def test_all
    $og1.manage_class Article
    $og2.manage_class User

    assert Article.ogmanager.store.is_a?(Og::MysqlStore) 
    assert User.ogmanager.store.is_a?(Og::PsqlStore) 
    
    a1 = Article.create('hello')
    a2 = Article.create('world')
    
    u = User.create('gmosx')
    
    assert_equal 2, Article.count
    
    u.articles << a1
    u.articles << a2
    
    gmosx = User.find_by_name('gmosx')
    assert_equal 2, gmosx.articles.size
    assert_equal 'hello', gmosx.articles[0].title
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
og-0.22.0 test/og/tc_multiple.rb
og-0.23.0 test/og/tc_multiple.rb