diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-02-14 06:12:51 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-14 06:12:51 +0900 |
commit | 840f55567191c96bdf4250a339759dbb532d351e (patch) | |
tree | f94a181eb7c660e3b7fa09af49ba37b9bfe561dd /activerecord/test | |
parent | af6ade0cfd09e3d3d9ebd304a2afae4d60a044dc (diff) | |
parent | 4f2a635661077fd5c3097e2a4c1496760600132a (diff) | |
download | rails-840f55567191c96bdf4250a339759dbb532d351e.tar.gz rails-840f55567191c96bdf4250a339759dbb532d351e.tar.bz2 rails-840f55567191c96bdf4250a339759dbb532d351e.zip |
Merge pull request #35258 from kamipo/revert_32380
Revert "Chaining named scope is no longer leaking to class level querying methods"
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/scoping/named_scoping_test.rb | 5 | ||||
-rw-r--r-- | activerecord/test/models/reply.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/topic.rb | 3 |
3 files changed, 4 insertions, 6 deletions
diff --git a/activerecord/test/cases/scoping/named_scoping_test.rb b/activerecord/test/cases/scoping/named_scoping_test.rb index 27f9df295f..1a3a95f168 100644 --- a/activerecord/test/cases/scoping/named_scoping_test.rb +++ b/activerecord/test/cases/scoping/named_scoping_test.rb @@ -447,9 +447,8 @@ 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 + def test_class_method_in_scope + assert_equal [topics(:second)], topics(:first).approved_replies.ordered end def test_nested_scoping diff --git a/activerecord/test/models/reply.rb b/activerecord/test/models/reply.rb index 0807bcf875..b35623a344 100644 --- a/activerecord/test/models/reply.rb +++ b/activerecord/test/models/reply.rb @@ -7,6 +7,8 @@ class Reply < Topic belongs_to :topic_with_primary_key, class_name: "Topic", primary_key: "title", foreign_key: "parent_title", counter_cache: "replies_count", touch: true has_many :replies, class_name: "SillyReply", dependent: :destroy, foreign_key: "parent_id" has_many :silly_unique_replies, dependent: :destroy, foreign_key: "parent_id" + + scope :ordered, -> { Reply.order(:id) } end class SillyReply < Topic diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb index fdb461ed7f..75890c327a 100644 --- a/activerecord/test/models/topic.rb +++ b/activerecord/test/models/topic.rb @@ -10,9 +10,6 @@ class Topic < ActiveRecord::Base scope :approved, -> { where(approved: true) } scope :rejected, -> { where(approved: false) } - scope :children, -> { where.not(parent_id: nil) } - scope :has_children, -> { where(id: Topic.children.select(:parent_id)) } - scope :scope_with_lambda, lambda { all } scope :by_lifo, -> { where(author_name: "lifo") } |