Sha256: c108aec6415bb5410e4c30a55bdda7150169ac345f070bae24a956cab057c6f8
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
$:.unshift File.join(File.dirname(__FILE__), 'lib') 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( =begin :destroy => true, :store => :sqlite, :name => 'test' =end :store => :mysql, :name => 'testreverse', :user => 'root', :password => 'navelrulez' ) 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
og-0.22.0 | test/og/tc_polymorphic.rb |
og-0.23.0 | test/og/tc_polymorphic.rb |