diff options
author | Will Bryant <will.bryant@gmail.com> | 2009-08-13 12:38:20 +1200 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-23 15:19:17 -0800 |
commit | b79823832e6cd30a9f14f97ffdf1642d4d63d4ea (patch) | |
tree | 632bcb449dadda458b4597c9dbb1a452ab4b7de8 /activerecord/test/cases/associations | |
parent | c6db37e69b1ff07f7ad535d4752d0e6eb2d15bff (diff) | |
download | rails-b79823832e6cd30a9f14f97ffdf1642d4d63d4ea.tar.gz rails-b79823832e6cd30a9f14f97ffdf1642d4d63d4ea.tar.bz2 rails-b79823832e6cd30a9f14f97ffdf1642d4d63d4ea.zip |
Verify that has_one :through preload respects the :conditions [#2976 state:resolved]
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/has_one_through_associations_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_one_through_associations_test.rb b/activerecord/test/cases/associations/has_one_through_associations_test.rb index f6307e6cf0..f6365e0216 100644 --- a/activerecord/test/cases/associations/has_one_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_one_through_associations_test.rb @@ -84,6 +84,18 @@ class HasOneThroughAssociationsTest < ActiveRecord::TestCase assert_not_nil assert_no_queries {members[0].sponsor_club} end + def test_has_one_through_with_conditions_eager_loading + # conditions on the through table + assert_equal clubs(:moustache_club), Member.find(@member.id, :include => :favourite_club).favourite_club + memberships(:membership_of_favourite_club).update_attribute(:favourite, false) + assert_equal nil, Member.find(@member.id, :include => :favourite_club).favourite_club + + # conditions on the source table + assert_equal clubs(:moustache_club), Member.find(@member.id, :include => :hairy_club).hairy_club + clubs(:moustache_club).update_attribute(:name, "Association of Clean-Shaven Persons") + assert_equal nil, Member.find(@member.id, :include => :hairy_club).hairy_club + end + def test_has_one_through_polymorphic_with_source_type assert_equal members(:groucho), clubs(:moustache_club).sponsored_member end |