diff options
author | Rick Olson <technoweenie@gmail.com> | 2006-12-19 03:10:39 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2006-12-19 03:10:39 +0000 |
commit | 41466a4c83e3e590b580d5d2cbc5869e601e7599 (patch) | |
tree | 2bb9c1b4274a3efa6f599f36caf2a63971765591 /activerecord/test/inheritance_test.rb | |
parent | d68f559640fcfa41174f544c38c9ac4aff216a26 (diff) | |
download | rails-41466a4c83e3e590b580d5d2cbc5869e601e7599.tar.gz rails-41466a4c83e3e590b580d5d2cbc5869e601e7599.tar.bz2 rails-41466a4c83e3e590b580d5d2cbc5869e601e7599.zip |
fix faulty inheritance tests and that eager loading grabs the wrong inheritance column when the class of your association is an STI subclass. Closes #6859 [protocool]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5744 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/inheritance_test.rb')
-rwxr-xr-x | activerecord/test/inheritance_test.rb | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/activerecord/test/inheritance_test.rb b/activerecord/test/inheritance_test.rb index 6d559d8539..20f9225004 100755 --- a/activerecord/test/inheritance_test.rb +++ b/activerecord/test/inheritance_test.rb @@ -4,7 +4,7 @@ require 'fixtures/project' require 'fixtures/subscriber' class InheritanceTest < Test::Unit::TestCase - fixtures :companies, :projects, :subscribers + fixtures :companies, :projects, :subscribers, :accounts def test_a_bad_type_column #SQLServer need to turn Identity Insert On before manually inserting into the Identity column @@ -134,6 +134,18 @@ class InheritanceTest < Test::Unit::TestCase test_complex_inheritance switch_to_default_inheritance_column end + + def test_eager_load_belongs_to_something_inherited + account = Account.find(1, :include => :firm) + assert_not_nil account.instance_variable_get("@firm"), "nil proves eager load failed" + end + + def test_alt_eager_loading + switch_to_alt_inheritance_column + test_eager_load_belongs_to_something_inherited + switch_to_default_inheritance_column + ActiveRecord::Base.logger.debug "cocksucker" + end def test_inheritance_without_mapping assert_kind_of SpecialSubscriber, SpecialSubscriber.find("webster132") @@ -148,9 +160,10 @@ class InheritanceTest < Test::Unit::TestCase c.save end [ Company, Firm, Client].each { |klass| klass.reset_column_information } - def Company.inheritance_column; @inheritance_column ||= "ruby_type"; end + Company.set_inheritance_column('ruby_type') end def switch_to_default_inheritance_column [ Company, Firm, Client].each { |klass| klass.reset_column_information } + Company.set_inheritance_column('type') end end |