From 41466a4c83e3e590b580d5d2cbc5869e601e7599 Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Tue, 19 Dec 2006 03:10:39 +0000 Subject: 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 --- activerecord/test/inheritance_test.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'activerecord/test') 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 -- cgit v1.2.3