Sha256: efc43dd748a9c650719e2fe953b068e448cfb97dbe9d64dcdabbb72c1ff39cf2

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 KB

Contents

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

require 'test/unit'
require 'ostruct'

require 'og'

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

	# Forward declaration.

	class Comment; end
	
	class Article
		property :name, String
		property :age, Fixnum
		has_many :comments, Comment

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

	class Comment
		prop_accessor :text, String
		belongs_to :article, Article

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

	def setup
	end

	def teardown
	end

	def test_all
		par = Article.__meta[:props_and_relations]
		assert_equal 3, par.size
		assert_equal N::Property, par[1].class
		assert_equal Og::HasMany, par[2].class

		par = Comment.__meta[:props_and_relations]
		assert_equal 3, par.size
		assert_equal N::Property, par[0].class
		assert_equal Og::BelongsTo, par[1].class
		assert_equal 'article_oid', par[1].meta[:property].to_s
		assert_equal String, par[0].klass
		assert_equal Article, par[1].foreign_class
	end

end

Version data entries

7 entries across 7 versions & 2 rubygems

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