From 6711a466a49edb182542d636c7ae17609f0f096d Mon Sep 17 00:00:00 2001 From: Tim Connor Date: Thu, 18 Jun 2009 16:03:05 -0700 Subject: [PATCH] has_many :through test_respects_select_class_on_scope --- .../has_many_through_associations_test.rb | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb index 4254bad..06a1b71 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -282,4 +282,14 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase def test_has_many_association_through_a_has_many_association_with_nonstandard_primary_keys assert_equal 1, owners(:blackbeard).toys.count end + + def test_respects_select_class_on_scope + michael = people(:michael) + #for comparison, until the test is passing + #posts = Post.scoped({:select => 'SUM(comments_count) as comments_count, SUM(taggings_count) as taggings_count', :group => :type}) + posts = michael.posts.scoped({:select => 'SUM(comments_count) as comments_count, SUM(taggings_count) as taggings_count', :group => :type}) + assert_equal 1, posts.length #change to 3 if running the Post. query instead + assert_nil posts.first.id + assert_equal 2, posts.first.comments_count + end end -- 1.6.1