require File.join(File.dirname(__FILE__), 'CONFIG.rb') require 'rubygems' require 'facets' require 'test/unit' require 'og' class TC_CamelCase < Test::Unit::TestCase # :nodoc: all include Og class CategoryCamelCase property :title, String def initialize(title) @title = title end end class ArticleCamelCase property :title, String joins_many CategoryCamelCase, :through => ArticleToCategory def initialize(title) @title = title end end class ArticleToCategory property :rate, Float property :hits, Fixnum has_one ArticleCamelCase has_one CategoryCamelCase end def setup $og1.manage_classes(CategoryCamelCase, ArticleCamelCase, ArticleToCategory) end def test_all c1 = CategoryCamelCase.create('tech') c2 = CategoryCamelCase.create('funny') a = ArticleCamelCase.create('a1') a.category_camel_cases.push(c1, :hits =>3, :rate => 2.3) a.category_camel_cases.push(c2, :rate => 1.2) join = a.category_camel_case_join_data(c1) assert_equal 2.3, join.rate assert_equal 3, join.hits join = a.category_camel_case_join_data(c2) assert_equal 1.2, join.rate assert_equal nil, join.hits end end