aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-01-23 12:04:13 -0700
committerSean Griffin <sean@thoughtbot.com>2015-01-23 12:05:14 -0700
commitb9d668f8cb466ab70e107e8ed6e1df2d28c25f31 (patch)
treec1213b08840355cd4c1390c50e81547018e6746b /activerecord/test/cases
parent2698e187578d29292eef3e1cb54338a3afd45a1f (diff)
downloadrails-b9d668f8cb466ab70e107e8ed6e1df2d28c25f31.tar.gz
rails-b9d668f8cb466ab70e107e8ed6e1df2d28c25f31.tar.bz2
rails-b9d668f8cb466ab70e107e8ed6e1df2d28c25f31.zip
Don't remove join dependencies in `Relation#exists?`
Fixes #18632
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/relations_test.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index 9631ea79be..d272b9b929 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -857,6 +857,12 @@ class RelationTest < ActiveRecord::TestCase
assert ! fake.exists?(authors(:david).id)
end
+ def test_exists_uses_existing_scope
+ post = authors(:david).posts.first
+ authors = Author.includes(:posts).where(name: "David", posts: { id: post.id })
+ assert authors.exists?(authors(:david).id)
+ end
+
def test_last
authors = Author.all
assert_equal authors(:bob), authors.last