From d7a910e31e839e5544aa9f83f9922ecfcee74ed5 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Mon, 16 May 2011 17:07:21 +0100 Subject: Fix problem with loading polymorphic associations which have been defined in an abstract superclass. Fixes #552. --- activerecord/test/cases/associations/has_many_associations_test.rb | 7 +++++++ activerecord/test/cases/reflection_test.rb | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index 522ac56d82..43974fd895 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -11,6 +11,7 @@ require 'models/comment' require 'models/person' require 'models/reader' require 'models/tagging' +require 'models/tag' require 'models/invoice' require 'models/line_item' require 'models/car' @@ -1468,4 +1469,10 @@ class HasManyAssociationsTest < ActiveRecord::TestCase bulb = car.bulbs.build({ :bulb_type => :custom }, :as => :admin) assert_equal CustomBulb, bulb.class end + + def test_abstract_class_with_polymorphic_has_many + post = SubStiPost.create! :title => "fooo", :body => "baa" + tagging = Tagging.create! :taggable => post + assert_equal [tagging], post.taggings + end end diff --git a/activerecord/test/cases/reflection_test.rb b/activerecord/test/cases/reflection_test.rb index 97d9669483..7e4ae1ea8d 100644 --- a/activerecord/test/cases/reflection_test.rb +++ b/activerecord/test/cases/reflection_test.rb @@ -216,7 +216,7 @@ class ReflectionTest < ActiveRecord::TestCase def test_conditions expected = [ [{ :tags => { :name => 'Blue' } }], - [{ :taggings => { :comment => 'first' } }, { "taggable_type" => "Post" }], + [{ :taggings => { :comment => 'first' } }], [{ :posts => { :title => ['misc post by bob', 'misc post by mary'] } }] ] actual = Author.reflect_on_association(:misc_post_first_blue_tags).conditions @@ -224,7 +224,7 @@ class ReflectionTest < ActiveRecord::TestCase expected = [ [{ :tags => { :name => 'Blue' } }, { :taggings => { :comment => 'first' } }, { :posts => { :title => ['misc post by bob', 'misc post by mary'] } }], - [{ "taggable_type" => "Post" }], + [], [] ] actual = Author.reflect_on_association(:misc_post_first_blue_tags_2).conditions -- cgit v1.2.3