Sha256: 6e4e582ed61f568e82606c79034505f08088d1a0b346d1b4c54bb7a28efc3d69
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
require File.join(File.dirname(__FILE__), 'CONFIG.rb') require 'rubygems' require 'facets' require 'test/unit' require 'og' class TC_OgPolymorphic < Test::Unit::TestCase # :nodoc: all include Og # This class is a polymorphic parent. Ie' it acts as template # to generate customized versions of this class. class Comment property :body, String belongs_to :parent, Object # polymorphic marker ! def initialize(body) @body = body end end class Article property :title, String has_many Comment def initialize(title) @title = title end end class User property :name, String has_many Comment def initialize(name) @name = name end end def setup @og = Og.setup($og_config) end def test_all u = User.create('gmosx') u.comments << User::Comment.create('Hello') u.comments << User::Comment.create('World') assert_equal 2, u.comments.size a = Article.create('test') a.comments << Article::Comment.create('Hello2') a.comments << Article::Comment.create('World2') assert_equal 2, a.comments.size end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
og-0.27.0 | test/og/tc_polymorphic.rb |