From 373b053dc8b99dac1abc3879a17a2bf8c30302b5 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Mon, 13 Jul 2009 16:25:33 +0100 Subject: Optimize _ids for hm:t with belongs_to source --- .../test/cases/associations/has_many_through_associations_test.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'activerecord/test/cases/associations') 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 7a4712d7c8..8529ff0285 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -243,8 +243,12 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase assert_equal 2, people(:michael).jobs.size end - def test_get_ids - assert_equal [posts(:welcome).id, posts(:authorless).id].sort, people(:michael).post_ids.sort + def test_get_ids_for_belongs_to_source + assert_sql(/DISTINCT/) { assert_equal [posts(:welcome).id, posts(:authorless).id].sort, people(:michael).post_ids.sort } + end + + def test_get_ids_for_has_many_source + assert_equal [comments(:eager_other_comment1).id], authors(:mary).comment_ids end def test_get_ids_for_loaded_associations -- cgit v1.2.3