aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/eager_test.rb
diff options
context:
space:
mode:
authorPavel Forkert <fxposter@gmail.com>2011-02-27 23:40:10 +0200
committerAaron Patterson <aaron.patterson@gmail.com>2011-04-22 12:06:15 -0500
commit96acdd3ec48594635314e768bf18805af6a40dde (patch)
tree9c3ca5bfd4a841f0d69afa3c113c999776301291 /activerecord/test/cases/associations/eager_test.rb
parentfe4932b531ec9b593085c4bb115c13f0852c3fbb (diff)
downloadrails-96acdd3ec48594635314e768bf18805af6a40dde.tar.gz
rails-96acdd3ec48594635314e768bf18805af6a40dde.tar.bz2
rails-96acdd3ec48594635314e768bf18805af6a40dde.zip
Added test case and fix for proper eager loading associations
Diffstat (limited to 'activerecord/test/cases/associations/eager_test.rb')
-rw-r--r--activerecord/test/cases/associations/eager_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb
index 40c82f2fb8..9bc7910fc6 100644
--- a/activerecord/test/cases/associations/eager_test.rb
+++ b/activerecord/test/cases/associations/eager_test.rb
@@ -170,6 +170,16 @@ class EagerAssociationTest < ActiveRecord::TestCase
assert_equal [comment], category.posts[0].comments
end
end
+
+ def test_associations_loaded_for_all_records
+ post = Post.create!(:title => 'foo', :body => "I like cars!")
+ comment = SpecialComment.create!(:body => 'Come on!', :post => post)
+ first_category = Category.create! :name => 'First!', :posts => [post]
+ second_category = Category.create! :name => 'Second!', :posts => [post]
+
+ categories = Category.where(:id => [first_category.id, second_category.id]).includes(:posts => :special_comments)
+ assert_equal categories.map { |category| category.posts.first.special_comments.loaded? }, [true, true]
+ end
def test_finding_with_includes_on_has_many_association_with_same_include_includes_only_once
author_id = authors(:david).id