Sha256: 4bc555940e09a891ff8dd6d6d52f8699adae3886f7838f4123dfe8219c8fe2c8

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
og-0.41.0 test/og/tc_camel_case_join.rb
og-0.30.0 test/og/tc_camel_case_join.rb
og-0.31.0 test/og/tc_camel_case_join.rb
og-0.40.0 test/og/tc_camel_case_join.rb