aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/inner_join_association_test.rb
diff options
context:
space:
mode:
authorMatt Jones <al2o3cr@gmail.com>2014-02-21 17:58:40 -0500
committerMatt Jones <al2o3cr@gmail.com>2014-02-21 17:58:40 -0500
commit70a5e5638bfd3b2543bb9d4805cbefec84b6b1ce (patch)
treea0d586612e71950a8dca78b1aa21ea0a0f0cf83f /activerecord/test/cases/associations/inner_join_association_test.rb
parent467cb908dd5f40cbfefe41b93e219682a3ced535 (diff)
downloadrails-70a5e5638bfd3b2543bb9d4805cbefec84b6b1ce.tar.gz
rails-70a5e5638bfd3b2543bb9d4805cbefec84b6b1ce.tar.bz2
rails-70a5e5638bfd3b2543bb9d4805cbefec84b6b1ce.zip
Pass a base relation to build_default_scope when joining
This allows the default scope to be built using the current table alias. Resolves #12770
Diffstat (limited to 'activerecord/test/cases/associations/inner_join_association_test.rb')
-rw-r--r--activerecord/test/cases/associations/inner_join_association_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/inner_join_association_test.rb b/activerecord/test/cases/associations/inner_join_association_test.rb
index a9efa6d86a..b23517b2f9 100644
--- a/activerecord/test/cases/associations/inner_join_association_test.rb
+++ b/activerecord/test/cases/associations/inner_join_association_test.rb
@@ -117,4 +117,13 @@ class InnerJoinAssociationTest < ActiveRecord::TestCase
assert_equal [author], Author.where(id: author).joins(:special_categorizations)
end
+
+ test "the default scope of the target is correctly aliased when joining associations" do
+ author = Author.create! name: "Jon"
+ author.categories.create! name: 'Not Special'
+ author.special_categories.create! name: 'Special'
+
+ categories = author.categories.includes(:special_categorizations).references(:special_categorizations).to_a
+ assert_equal 2, categories.size
+ end
end