diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-03-05 20:10:24 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-03-05 20:10:24 +0000 |
commit | ddf83d14f1c7ddae07a285a8ad7c45f652edc843 (patch) | |
tree | f46cb89576a6267e6a501acec783ee12c1805a89 /activerecord/test/cases | |
parent | 4206eff1895dccadcbec471798bfbd129404cc94 (diff) | |
download | rails-ddf83d14f1c7ddae07a285a8ad7c45f652edc843.tar.gz rails-ddf83d14f1c7ddae07a285a8ad7c45f652edc843.tar.bz2 rails-ddf83d14f1c7ddae07a285a8ad7c45f652edc843.zip |
Add a test for STI on the through where the through is nested, and change the code which support this
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/nested_through_associations_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/nested_through_associations_test.rb b/activerecord/test/cases/associations/nested_through_associations_test.rb index a4ac69782a..0dd407f342 100644 --- a/activerecord/test/cases/associations/nested_through_associations_test.rb +++ b/activerecord/test/cases/associations/nested_through_associations_test.rb @@ -425,6 +425,15 @@ class NestedThroughAssociationsTest < ActiveRecord::TestCase assert !scope.where("comments.type" => "SubSpecialComment").empty? end + def test_has_many_through_with_sti_on_nested_through_reflection + taggings = posts(:sti_comments).special_comments_ratings_taggings + assert_equal [taggings(:special_comment_rating)], taggings + + scope = Post.joins(:special_comments_ratings_taggings).where(:id => posts(:sti_comments).id) + assert scope.where("comments.type" => "Comment").empty? + assert !scope.where("comments.type" => "SpecialComment").empty? + end + def test_nested_has_many_through_writers_should_raise_error david = authors(:david) subscriber = subscribers(:first) |