aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-09-07 07:33:38 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-09-07 07:43:44 +0900
commit3acc5d6ef7b3f000d0c541b9dc2881a8b7f40f75 (patch)
tree24d85800fdf8b5da44d07fa4fd2a55306914d4c9 /activerecord/test/cases/associations
parent0a94612a979762e1bbeb9cff13322e3f9f721ca3 (diff)
downloadrails-3acc5d6ef7b3f000d0c541b9dc2881a8b7f40f75.tar.gz
rails-3acc5d6ef7b3f000d0c541b9dc2881a8b7f40f75.tar.bz2
rails-3acc5d6ef7b3f000d0c541b9dc2881a8b7f40f75.zip
`has_many :through` with unscope should affect to through scope
The order of scope evaluation should be from through scope to the association's own scope. Otherwise the association's scope cannot affect to through scope. Fixes #13677. Closes #28449.
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb
index f8ea51225a..521b388cee 100644
--- a/activerecord/test/cases/associations/has_many_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb
@@ -1250,6 +1250,10 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
TenantMembership.current_member = nil
end
+ def test_has_many_through_with_unscope_should_affect_to_through_scope
+ assert_equal [comments(:eager_other_comment1)], authors(:mary).unordered_comments
+ end
+
def test_has_many_through_with_scope_should_respect_table_alias
family = Family.create!
users = 3.times.map { User.create! }