aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-10-20 15:25:29 -0600
committerSean Griffin <sean@seantheprogrammer.com>2015-10-20 15:25:29 -0600
commit0a6c4019dfebb1c46d8c16c89238a05a6fdc9f1d (patch)
tree04b08b1a07a11f4db329c82cc2229b8decaafe23 /activerecord/test
parent7b92798d2fee012bf683c513fb3864a9143a6f71 (diff)
parentf798cbd2f36ed8a4b825667016d6975b812a5b9f (diff)
downloadrails-0a6c4019dfebb1c46d8c16c89238a05a6fdc9f1d.tar.gz
rails-0a6c4019dfebb1c46d8c16c89238a05a6fdc9f1d.tar.bz2
rails-0a6c4019dfebb1c46d8c16c89238a05a6fdc9f1d.zip
Merge pull request #20957 from akihiro17/find-by-issue
Fix find_by with association subquery issue
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/finder_test.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index 307b68764e..6686ce012d 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -265,6 +265,12 @@ class FinderTest < ActiveRecord::TestCase
assert_equal [Account], accounts.collect(&:class).uniq
end
+ def test_find_by_association_subquery
+ author = authors(:david)
+ assert_equal author.post, Post.find_by(author: Author.where(id: author))
+ assert_equal author.post, Post.find_by(author_id: Author.where(id: author))
+ end
+
def test_take
assert_equal topics(:first), Topic.take
end