diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-02-06 02:29:50 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-06 02:29:50 +0900 |
commit | 92c75c312f610c253692dd28d3f38381edbb318e (patch) | |
tree | d16bdddb4dcba3ee1331b83e95fcb429c3bd6458 /activerecord/test/cases | |
parent | 287920ca7d06c8f51198ec750d65ba703835b257 (diff) | |
parent | 2935d07569337aeaa06d03a56180d235a7fbbebf (diff) | |
download | rails-92c75c312f610c253692dd28d3f38381edbb318e.tar.gz rails-92c75c312f610c253692dd28d3f38381edbb318e.tar.bz2 rails-92c75c312f610c253692dd28d3f38381edbb318e.zip |
Merge pull request #32380 from kamipo/fix_leaking_scope
Chaining named scope is no longer leaking to class level querying methods
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/scoping/named_scoping_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/scoping/named_scoping_test.rb b/activerecord/test/cases/scoping/named_scoping_test.rb index 418a2ae04e..27f9df295f 100644 --- a/activerecord/test/cases/scoping/named_scoping_test.rb +++ b/activerecord/test/cases/scoping/named_scoping_test.rb @@ -447,6 +447,16 @@ class NamedScopingTest < ActiveRecord::TestCase assert_equal [posts(:sti_comments)], Post.with_special_comments.with_post(4).to_a.uniq end + def test_chaining_doesnt_leak_conditions_to_another_scopes + expected = Topic.where(approved: false).where(id: Topic.children.select(:parent_id)) + assert_equal expected.to_a, Topic.rejected.has_children.to_a + end + + def test_nested_scoping + expected = Reply.approved + assert_equal expected.to_a, Topic.rejected.nested_scoping(expected) + end + def test_scopes_batch_finders assert_equal 4, Topic.approved.count |