diff options
author | Xavier Noria <fxn@hashref.com> | 2011-04-23 01:16:21 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2011-04-23 01:16:21 +0200 |
commit | 384dbfd1408721ded071a587b0dc9ee40203607e (patch) | |
tree | 770854b984691dea8187ca0a998a28e93a008093 /activerecord/test/cases/associations/eager_test.rb | |
parent | 900470cf3cd346ad1b17cf6902f3f98e6dae7709 (diff) | |
parent | af1b48926f49226c934995c322ee017239158cf3 (diff) | |
download | rails-384dbfd1408721ded071a587b0dc9ee40203607e.tar.gz rails-384dbfd1408721ded071a587b0dc9ee40203607e.tar.bz2 rails-384dbfd1408721ded071a587b0dc9ee40203607e.zip |
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'activerecord/test/cases/associations/eager_test.rb')
-rw-r--r-- | activerecord/test/cases/associations/eager_test.rb | 10 |
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 |