aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/scoping
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2016-02-11 11:33:30 -0700
committerSean Griffin <sean@seantheprogrammer.com>2016-02-11 11:33:30 -0700
commit6fedc7d56a580d1ef7e923d95865bd99626d2f21 (patch)
treee796622611491add0c8349d3fb1b9296d92a3cc8 /activerecord/test/cases/scoping
parent848f70e18406e3c9bd952074ce627e82a474dda7 (diff)
parent12e9e38d9a550f77936c29d14a8b8156cdfa81be (diff)
downloadrails-6fedc7d56a580d1ef7e923d95865bd99626d2f21.tar.gz
rails-6fedc7d56a580d1ef7e923d95865bd99626d2f21.tar.bz2
rails-6fedc7d56a580d1ef7e923d95865bd99626d2f21.zip
Merge pull request #18109 from k0kubun/unscoped-joins
Allow `joins` to be unscoped Fixes #13775
Diffstat (limited to 'activerecord/test/cases/scoping')
-rw-r--r--activerecord/test/cases/scoping/default_scoping_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/scoping/default_scoping_test.rb b/activerecord/test/cases/scoping/default_scoping_test.rb
index ad5ca70f36..c918cbdef5 100644
--- a/activerecord/test/cases/scoping/default_scoping_test.rb
+++ b/activerecord/test/cases/scoping/default_scoping_test.rb
@@ -374,6 +374,18 @@ class DefaultScopingTest < ActiveRecord::TestCase
assert_equal 10, DeveloperCalledJamis.unscoped { DeveloperCalledJamis.poor }.length
end
+ def test_default_scope_with_joins
+ assert_equal Comment.where(post_id: SpecialPostWithDefaultScope.pluck(:id)).count,
+ Comment.joins(:special_post_with_default_scope).count
+ assert_equal Comment.where(post_id: Post.pluck(:id)).count,
+ Comment.joins(:post).count
+ end
+
+ def test_unscoped_with_joins_should_not_have_default_scope
+ assert_equal SpecialPostWithDefaultScope.unscoped { Comment.joins(:special_post_with_default_scope).to_a },
+ Comment.joins(:post).to_a
+ end
+
def test_default_scope_select_ignored_by_aggregations
assert_equal DeveloperWithSelect.all.to_a.count, DeveloperWithSelect.count
end