diff options
author | Frederick Cheung <frederick.cheung@gmail.com> | 2008-08-25 22:36:19 +0100 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-08-25 20:49:55 -0700 |
commit | b7a37b742c0abd1df8ea48cc82f76385cc0c41ea (patch) | |
tree | 2f2956ee7d2da26c1c8e13ddb0489f5eaaf0e4e4 /activerecord/test | |
parent | f2d8d13c6495f2a9b3bbf3b50d869c0e5b25c207 (diff) | |
download | rails-b7a37b742c0abd1df8ea48cc82f76385cc0c41ea.tar.gz rails-b7a37b742c0abd1df8ea48cc82f76385cc0c41ea.tar.bz2 rails-b7a37b742c0abd1df8ea48cc82f76385cc0c41ea.zip |
Fix preloading of has_one through associations
[#903 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/has_one_through_associations_test.rb | 14 |
1 files changed, 9 insertions, 5 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 3eb66bc941..4a5d7e27c1 100644 --- a/activerecord/test/cases/associations/has_one_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_one_through_associations_test.rb @@ -44,19 +44,23 @@ class HasOneThroughAssociationsTest < ActiveRecord::TestCase def test_has_one_through_polymorphic assert_equal clubs(:moustache_club), @member.sponsor_club end - + def has_one_through_to_has_many assert_equal 2, @member.fellow_members.size end - + def test_has_one_through_eager_loading - members = Member.find(:all, :include => :club, :conditions => ["name = ?", "Groucho Marx"]) + members = assert_queries(3) do #base table, through table, clubs table + Member.find(:all, :include => :club, :conditions => ["name = ?", "Groucho Marx"]) + end assert_equal 1, members.size assert_not_nil assert_no_queries {members[0].club} end - + def test_has_one_through_eager_loading_through_polymorphic - members = Member.find(:all, :include => :sponsor_club, :conditions => ["name = ?", "Groucho Marx"]) + members = assert_queries(3) do #base table, through table, clubs table + Member.find(:all, :include => :sponsor_club, :conditions => ["name = ?", "Groucho Marx"]) + end assert_equal 1, members.size assert_not_nil assert_no_queries {members[0].sponsor_club} end |