Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #10289: table_name_more_explicit_tests.diff

File table_name_more_explicit_tests.diff, 1.2 kB (added by scott_willson, 1 year ago)
  • test/fixtures/company_in_module.rb

    old new  
    1717    class Client < Company 
    1818      belongs_to :firm, :foreign_key => "client_of" 
    1919      belongs_to :firm_with_other_name, :class_name => "Firm", :foreign_key => "client_of" 
     20       
     21      class Contact < ActiveRecord::Base; end 
    2022    end 
    2123     
    2224    class Developer < ActiveRecord::Base 
  • test/modules_test.rb

    old new  
    3131    assert_kind_of MyApplication::Business::Firm, account.firm 
    3232  end 
    3333   
     34  def test_table_name 
     35    assert_equal 'accounts', MyApplication::Billing::Account.table_name, 'table_name for ActiveRecord model in module' 
     36    assert_equal 'companies', MyApplication::Business::Client.table_name, 'table_name for ActiveRecord model subclass' 
     37    assert_equal 'company_contacts', MyApplication::Business::Client::Contact.table_name, 'table_name for ActiveRecord model enclosed by another ActiveRecord model' 
     38  end 
     39   
    3440end