require File.join(File.dirname(__FILE__), 'CONFIG.rb') $DBG = true require 'test/unit' require 'og' class TC_Join < Test::Unit::TestCase # :nodoc: all include Og class Category property :title, String def initialize(title) @title = title end end class Article property :title, String joins_many Category, :through => ArticleToCategory def initialize(title) @title = title end end class ArticleToCategory property :rate, Float property :hits, Fixnum has_one Article has_one Category end def setup @og = Og.setup($og_config) end def test_all c1 = Category.create('tech') c2 = Category.create('funny') a = Article.create('a1') a.categories.push(c1, :hits =>3, :rate => 2.3) a.categories.push(c2, :rate => 1.2) join = a.category_join_data(c1) assert_equal 2.3, join.rate assert_equal 3, join.hits join = a.category_join_data(c2) assert_equal 1.2, join.rate assert_equal nil, join.hits end end