From 86aefdb4f2b957acc6d6c7eef557dff6a3888803 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Fri, 30 Mar 2012 16:18:39 +0100 Subject: Fix #5667. Preloading should ignore scoping. --- activerecord/test/cases/associations/eager_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index b27a93f857..efdb7cbb36 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -1169,4 +1169,15 @@ class EagerAssociationTest < ActiveRecord::TestCase assert_no_queries { assert_equal 1, posts[0].categories[1].categorizations.length } assert_no_queries { assert_equal 2, posts[1].categories[0].categorizations.length } end + + test "scoping with a circular preload" do + assert_equal Comment.find(1), Comment.preload(:post => :comments).scoping { Comment.find(1) } + end + + test "preload ignores the scoping" do + assert_equal( + Comment.find(1).post, + Post.where('1 = 0').scoping { Comment.preload(:post).find(1).post } + ) + end end -- cgit v1.2.3