From 9c3afdc327132c7f1f4d05eebc0c05b715442e7d Mon Sep 17 00:00:00 2001 From: Jefferson Lai Date: Mon, 10 Feb 2014 03:00:05 -0800 Subject: Fixes Issue #13466. Changed the call to a scope block to be evaluated with instance_eval. The result is that ScopeRegistry can use the actual class instead of base_class when caching scopes so queries made by classes with a common ancestor won't leak scopes. --- activerecord/test/cases/scoping/named_scoping_test.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'activerecord/test/cases/scoping') diff --git a/activerecord/test/cases/scoping/named_scoping_test.rb b/activerecord/test/cases/scoping/named_scoping_test.rb index f0ad9ebb8a..f66b76a7ad 100644 --- a/activerecord/test/cases/scoping/named_scoping_test.rb +++ b/activerecord/test/cases/scoping/named_scoping_test.rb @@ -2,12 +2,13 @@ require "cases/helper" require 'models/post' require 'models/topic' require 'models/comment' +require 'models/rating' require 'models/reply' require 'models/author' require 'models/developer' class NamedScopingTest < ActiveRecord::TestCase - fixtures :posts, :authors, :topics, :comments, :author_addresses + fixtures :posts, :authors, :topics, :comments, :author_addresses, :ratings def test_implements_enumerable assert !Topic.all.empty? @@ -115,6 +116,10 @@ class NamedScopingTest < ActiveRecord::TestCase assert_equal 1,SpecialPost.containing_the_letter_a.count end + def test_scope_subquery_with_STI + assert_nothing_raised { VerySpecialComment.special_parent(SpecialRating.first).count } + end + def test_has_many_through_associations_have_access_to_scopes assert_not_equal Comment.containing_the_letter_e, authors(:david).comments assert !Comment.containing_the_letter_e.empty? -- cgit v1.2.3