Sha256: a67c4463bacc6af213b1fa170d87e1c6a93a31f9ec4533c1d6d30021fb127a16

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

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

require 'test/unit'
require 'ostruct'

require 'og'

class TC_OgManyToMany < Test::Unit::TestCase # :nodoc: all
	include N

	class Attribute
		property :name, String
		
		def initialize(name = nil)
			@name = name
		end
	end

	class Klass
		property :name, String
		many_to_many :observed_attributes, Attribute, :linkback => :klass_observers
		many_to_many :controlled_attributes, Attribute, :linkback => :klass_controllers

		def initialize(name = nil)
			@name = name
		end
	end

	def test_all
		config = {
			:adapter => 'psql',
			:database => 'test',
			:user => 'postgres',
			:password => 'navelrulez',
			:connection_count => 2
		}

		Og::Database.drop_db!(config)
		og = Og::Database.new(config)

		og.get_connection

		k = Klass.create('klass1')
		a1 = Attribute.create('attr1')
		a2 = Attribute.create('attr2')

		k.add_observed_attribute(a1)
		k.add_observed_attribute(a2)

		assert_equal 2, k.observed_attributes.size
		assert_equal 1, a1.klass_observers.size

		k.add_controlled_attribute(a1)

		assert_equal 1, k.controlled_attributes.size
		assert_equal 1, a1.klass_controllers.size

		og.put_connection
		og.shutdown
	end

end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
nitro-0.12.0 test/og/tc_many_to_many.rb
og-0.12.0 test/og/tc_many_to_many.rb
og-0.13.0 test/og/tc_many_to_many.rb
og-0.14.0 test/og/tc_many_to_many.rb
og-0.15.0 test/og/tc_many_to_many.rb