From e0a6ec214987882a47722e709a91b17b8395bec9 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Fri, 5 Aug 2011 16:48:46 -0300 Subject: Fix test for Rubinius --- .../test/cases/associations/nested_through_associations_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/test/cases/associations/nested_through_associations_test.rb') diff --git a/activerecord/test/cases/associations/nested_through_associations_test.rb b/activerecord/test/cases/associations/nested_through_associations_test.rb index dd450a2a8e..80c6e41169 100644 --- a/activerecord/test/cases/associations/nested_through_associations_test.rb +++ b/activerecord/test/cases/associations/nested_through_associations_test.rb @@ -247,7 +247,7 @@ class NestedThroughAssociationsTest < ActiveRecord::TestCase def test_has_many_through_has_and_belongs_to_many_with_has_many_source_reflection_preload_via_joins assert_includes_and_joins_equal( - Category.where('comments.id' => comments(:more_greetings).id).order('comments.id'), + Category.where('comments.id' => comments(:more_greetings).id).order('categories.id'), [categories(:general), categories(:technology)], :post_comments ) end -- cgit v1.2.3 From 9bde73ff72812f6f3c59ad97be6ca6c628e109ea Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Tue, 6 Sep 2011 16:34:32 +0100 Subject: Nested through associations: preloads from the default scope of a through model should not be included in the association scope. (We're already excluding includes.) Fixes #2834. --- .../test/cases/associations/nested_through_associations_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'activerecord/test/cases/associations/nested_through_associations_test.rb') diff --git a/activerecord/test/cases/associations/nested_through_associations_test.rb b/activerecord/test/cases/associations/nested_through_associations_test.rb index 80c6e41169..6122098623 100644 --- a/activerecord/test/cases/associations/nested_through_associations_test.rb +++ b/activerecord/test/cases/associations/nested_through_associations_test.rb @@ -356,6 +356,15 @@ class NestedThroughAssociationsTest < ActiveRecord::TestCase assert_equal categories(:general), members(:groucho).club_category end + def test_has_one_through_has_one_through_with_belongs_to_source_reflection_with_default_scope_preload_on_the_through_model + prev_default_scope = Club.default_scopes + Club.default_scopes = [Club.preload(:category)] + + assert_equal categories(:general), members(:groucho).club_category + ensure + Club.default_scopes = prev_default_scope + end + def test_has_one_through_has_one_through_with_belongs_to_source_reflection_preload members = assert_queries(4) { Member.includes(:club_category).to_a.sort_by(&:id) } general = categories(:general) -- cgit v1.2.3 From 143769051bcf5b3a7600744be2d8db6e9c859288 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Wed, 7 Sep 2011 09:26:02 +0100 Subject: Don't include any of includes, preload, joins, eager_load in the through association scope. --- .../test/cases/associations/nested_through_associations_test.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'activerecord/test/cases/associations/nested_through_associations_test.rb') diff --git a/activerecord/test/cases/associations/nested_through_associations_test.rb b/activerecord/test/cases/associations/nested_through_associations_test.rb index 6122098623..530f5212a2 100644 --- a/activerecord/test/cases/associations/nested_through_associations_test.rb +++ b/activerecord/test/cases/associations/nested_through_associations_test.rb @@ -356,11 +356,13 @@ class NestedThroughAssociationsTest < ActiveRecord::TestCase assert_equal categories(:general), members(:groucho).club_category end - def test_has_one_through_has_one_through_with_belongs_to_source_reflection_with_default_scope_preload_on_the_through_model + def test_joins_and_includes_from_through_models_not_included_in_association prev_default_scope = Club.default_scopes - Club.default_scopes = [Club.preload(:category)] - assert_equal categories(:general), members(:groucho).club_category + [:includes, :preload, :joins, :eager_load].each do |q| + Club.default_scopes = [Club.send(q, :category)] + assert_equal categories(:general), members(:groucho).reload.club_category + end ensure Club.default_scopes = prev_default_scope end -- cgit v1.2.3