aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/eager_test.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2008-10-05 19:46:48 +0100
committerPratik Naik <pratiknaik@gmail.com>2008-10-05 19:46:48 +0100
commit6090513cfb8acb5554a6653a6f2cb87648585d41 (patch)
tree99bfd589a48153e33f19ae72baa6e98f5708a9b8 /activerecord/test/cases/associations/eager_test.rb
parent01159a6431bbc2dc7d7d95ce294c8567c954f39e (diff)
parent4df45d86097efbeabceecfe53d8ea2da9ccbb107 (diff)
downloadrails-6090513cfb8acb5554a6653a6f2cb87648585d41.tar.gz
rails-6090513cfb8acb5554a6653a6f2cb87648585d41.tar.bz2
rails-6090513cfb8acb5554a6653a6f2cb87648585d41.zip
Merge commit 'mainstream/master'
Conflicts: activerecord/lib/active_record/association_preload.rb
Diffstat (limited to 'activerecord/test/cases/associations/eager_test.rb')
-rw-r--r--activerecord/test/cases/associations/eager_test.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb
index e78624a98d..7f42577ab0 100644
--- a/activerecord/test/cases/associations/eager_test.rb
+++ b/activerecord/test/cases/associations/eager_test.rb
@@ -116,6 +116,13 @@ class EagerAssociationTest < ActiveRecord::TestCase
assert_equal 2, posts.first.comments.size
end
+ def test_loading_from_an_association_that_has_a_hash_of_conditions
+ assert_nothing_raised do
+ Author.find(:all, :include => :hello_posts_with_hash_conditions)
+ end
+ assert !Author.find(authors(:david).id, :include => :hello_posts_with_hash_conditions).hello_posts.empty?
+ end
+
def test_loading_with_no_associations
assert_nil Post.find(posts(:authorless).id, :include => :author).author
end
@@ -268,6 +275,15 @@ class EagerAssociationTest < ActiveRecord::TestCase
assert_equal authors(:david), assert_no_queries { posts_with_comments_and_author.first.author }
end
+ def test_eager_with_has_many_through_a_belongs_to_association
+ author = authors(:mary)
+ post = Post.create!(:author => author, :title => "TITLE", :body => "BODY")
+ author.author_favorites.create(:favorite_author_id => 1)
+ author.author_favorites.create(:favorite_author_id => 2)
+ posts_with_author_favorites = author.posts.find(:all, :include => :author_favorites)
+ assert_no_queries { posts_with_author_favorites.first.author_favorites.first.author_id }
+ end
+
def test_eager_with_has_many_through_an_sti_join_model
author = Author.find(:first, :include => :special_post_comments, :order => 'authors.id')
assert_equal [comments(:does_it_hurt)], assert_no_queries { author.special_post_comments }