Sha256: cbfab793725e665a84aba657d801e0f7a248808e5109a1bb0d2bc148944a92e4

Contents?: true

Size: 1008 Bytes

Versions: 2

Compression:

Stored size: 1008 Bytes

Contents

require File.join(File.dirname(__FILE__), 'CONFIG.rb')

require 'rubygems'
require 'facets'
require 'test/unit'

require 'og'

class TC_Override < Test::Unit::TestCase
  include Og

  class Book
    property :title, String
    belongs_to :owner, Person
  end

  class Person
    property :name, Og::VarChar(128)
    has_many :books, Book, :foreign_name => :owner
  end

  def setup
    @old_prefix = Og.table_prefix
    Og.table_prefix = nil
    $og1.manage_classes(Book, Person)
  end

  def teardown
    Og.table_prefix = @old_prefix
    @old_prefix = nil
  end

  def test_basic
    book = Book.create
    person = Person.create
    person.books << book
    
    assert_equal person.books.size, 1
  end
  
  # This tests, if the tables are without prefix, note that changing the
  # Class of the testcase will change the table name.
  
  def test_og_prefix
    assert_equal Book.table, 'tc_override_book'
    assert_equal Person.table, 'tc_override_person'
  end

end

# * Kristof Jozsa <dyn@ond.vein.hu>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
og-0.41.0 test/og/tc_override.rb
og-0.40.0 test/og/tc_override.rb