diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-10-02 06:39:42 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-10-09 09:45:32 +0900 |
commit | 723b526158df576f673c1bc28439744378a03f5d (patch) | |
tree | 664a936a632fe32a48e70c3f0767aa550a02d537 /activerecord/test | |
parent | f8337575ac1be1efb2bc89225a369e19fa2a234d (diff) | |
download | rails-723b526158df576f673c1bc28439744378a03f5d.tar.gz rails-723b526158df576f673c1bc28439744378a03f5d.tar.bz2 rails-723b526158df576f673c1bc28439744378a03f5d.zip |
Fix `relation.exists?` with has_many through associations
`relation.exists?` should reference correct aliases while joining tables
of has_many through associations.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/finder_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index 55496147c1..2f6d708092 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -9,6 +9,7 @@ require "models/company" require "models/tagging" require "models/topic" require "models/reply" +require "models/rating" require "models/entrant" require "models/project" require "models/developer" @@ -244,6 +245,13 @@ class FinderTest < ActiveRecord::TestCase assert_equal true, author.unique_categorized_posts.includes(:special_comments).order("comments.tags_count DESC").limit(1).exists? end + def test_exists_should_reference_correct_aliases_while_joining_tables_of_has_many_through_association + assert_nothing_raised do + developer = developers(:david) + developer.ratings.includes(comment: :post).where(posts: { id: 1 }).exists? + end + end + def test_exists_with_empty_table_and_no_args_given Topic.delete_all assert_equal false, Topic.exists? |