diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-27 10:29:59 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-27 10:29:59 -0700 |
commit | 85bfb08c1ad74454ddf17b60d2d5ae3429b87d2b (patch) | |
tree | d5e69cbfa8cca81e2fc3109335768cff16370051 /activerecord/test/cases | |
parent | 52434e9a512477d632b492793bcae5b4732ea689 (diff) | |
parent | c917fb7c35c8ef0f48963f44059e7088430bb2d0 (diff) | |
download | rails-85bfb08c1ad74454ddf17b60d2d5ae3429b87d2b.tar.gz rails-85bfb08c1ad74454ddf17b60d2d5ae3429b87d2b.tar.bz2 rails-85bfb08c1ad74454ddf17b60d2d5ae3429b87d2b.zip |
Merge pull request #14834 from al2o3cr/issue14155
Correctly alias table names when joining more than once
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/inner_join_association_test.rb | 10 |
1 files changed, 10 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 b23517b2f9..07cf65a760 100644 --- a/activerecord/test/cases/associations/inner_join_association_test.rb +++ b/activerecord/test/cases/associations/inner_join_association_test.rb @@ -126,4 +126,14 @@ class InnerJoinAssociationTest < ActiveRecord::TestCase categories = author.categories.includes(:special_categorizations).references(:special_categorizations).to_a assert_equal 2, categories.size end + + test "the correct records are loaded when including an aliased association" do + author = Author.create! name: "Jon" + author.categories.create! name: 'Not Special' + author.special_categories.create! name: 'Special' + + categories = author.categories.eager_load(:special_categorizations).order(:name).to_a + assert_equal 0, categories.first.special_categorizations.size + assert_equal 1, categories.second.special_categorizations.size + end end |