Sha256: 325aa97a04846c4647229f81e37f2c30ee4a246b09ffb222bf2248c9fbb3e282

Contents?: true

Size: 1.49 KB

Versions: 92

Compression:

Stored size: 1.49 KB

Contents

require 'abstract_unit'
require 'fixtures/company_in_module'

class ModulesTest < Test::Unit::TestCase
  fixtures :accounts, :companies, :projects, :developers

  def test_module_spanning_associations
    firm = MyApplication::Business::Firm.find(:first)
    assert !firm.clients.empty?, "Firm should have clients"
    assert_nil firm.class.table_name.match('::'), "Firm shouldn't have the module appear in its table name"
  end

  def test_module_spanning_has_and_belongs_to_many_associations
    project = MyApplication::Business::Project.find(:first)
    project.developers << MyApplication::Business::Developer.create("name" => "John")
    assert "John", project.developers.last.name
  end
  
  def test_associations_spanning_cross_modules
    account = MyApplication::Billing::Account.find(:first, :order => 'id')
    assert_kind_of MyApplication::Business::Firm, account.firm
    assert_kind_of MyApplication::Billing::Firm, account.qualified_billing_firm
    assert_kind_of MyApplication::Billing::Firm, account.unqualified_billing_firm
    assert_kind_of MyApplication::Billing::Nested::Firm, account.nested_qualified_billing_firm
    assert_kind_of MyApplication::Billing::Nested::Firm, account.nested_unqualified_billing_firm
  end
  
  def test_find_account_and_include_company
    account = MyApplication::Billing::Account.find(1, :include => :firm)
    assert_kind_of MyApplication::Business::Firm, account.instance_variable_get('@firm')
    assert_kind_of MyApplication::Business::Firm, account.firm
  end
  
end

Version data entries

92 entries across 92 versions & 7 rubygems

Version Path
jstorimer-deep-test-2.0.0 sample_rails_project/vendor/rails/activerecord/test/modules_test.rb
jstorimer-deep-test-1.4.0 sample_rails_project/vendor/rails/activerecord/test/modules_test.rb
jstorimer-deep-test-1.3.0 sample_rails_project/vendor/rails/activerecord/test/modules_test.rb
jstorimer-deep-test-1.2.0 sample_rails_project/vendor/rails/activerecord/test/modules_test.rb
jstorimer-deep-test-1.1.0 sample_rails_project/vendor/rails/activerecord/test/modules_test.rb
jstorimer-deep-test-1.0.0 sample_rails_project/vendor/rails/activerecord/test/modules_test.rb
jstorimer-deep-test-0.2.0 sample_rails_project/vendor/rails/activerecord/test/modules_test.rb
jstorimer-deep-test-0.1.0 sample_rails_project/vendor/rails/activerecord/test/modules_test.rb
activerecord-1.15.1 test/modules_test.rb
activerecord-1.15.2 test/modules_test.rb
activerecord-1.15.3 test/modules_test.rb
activerecord-1.15.4 test/modules_test.rb
activerecord-1.15.0 test/modules_test.rb
activerecord-1.15.6 test/modules_test.rb
activerecord-1.15.5 test/modules_test.rb
activerecord-2.0.1 test/modules_test.rb
activerecord-2.0.5 test/modules_test.rb
activerecord-2.0.2 test/modules_test.rb
activerecord-2.0.0 test/modules_test.rb
activerecord-2.0.4 test/modules_test.rb