aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-07-09 11:37:48 +0100
committerJon Leighton <j@jonathanleighton.com>2011-07-09 11:39:04 +0100
commit111968d4024fdccc386979551cdfc7799b39cff0 (patch)
tree1f310d0a4e2947dc56a5f02fc92024cda0240ef4 /activerecord/test/cases/associations
parentb65bd01d555651e278099ec2fe5cf9c7db7608d9 (diff)
downloadrails-111968d4024fdccc386979551cdfc7799b39cff0.tar.gz
rails-111968d4024fdccc386979551cdfc7799b39cff0.tar.bz2
rails-111968d4024fdccc386979551cdfc7799b39cff0.zip
Foo.joins(:bar).includes(:bar) should result in a single query with :bar as a join. Related: #1873.
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r--activerecord/test/cases/associations/eager_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb
index 325fc58958..f1d061133c 100644
--- a/activerecord/test/cases/associations/eager_test.rb
+++ b/activerecord/test/cases/associations/eager_test.rb
@@ -1040,4 +1040,12 @@ class EagerAssociationTest < ActiveRecord::TestCase
}
assert_no_queries { assert_equal groucho, sponsor.thing }
end
+
+ def test_joins_with_includes_should_preload_via_joins
+ post = assert_queries(1) { Post.includes(:comments).joins(:comments).order('posts.id desc').to_a.first }
+
+ assert_queries(0) do
+ assert_not_equal 0, post.comments.to_a.count
+ end
+ end
end