aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2006-03-19 03:05:21 +0000
committerRick Olson <technoweenie@gmail.com>2006-03-19 03:05:21 +0000
commit9412c0531d53c8070ab0787a00ceb0782736d8d2 (patch)
tree9b7deadfa9a5ffb5f989ddb905c95009e6ed88d3 /activerecord/test
parent3f77a04cb5244111354b61b97b06ead49a153d29 (diff)
downloadrails-9412c0531d53c8070ab0787a00ceb0782736d8d2.tar.gz
rails-9412c0531d53c8070ab0787a00ceb0782736d8d2.tar.bz2
rails-9412c0531d53c8070ab0787a00ceb0782736d8d2.zip
Eager Loading support added for has_many :through => :has_many associations (see below). [Rick Olson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3967 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/associations_join_model_test.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/activerecord/test/associations_join_model_test.rb b/activerecord/test/associations_join_model_test.rb
index 4b0f4e4c33..db5f362610 100644
--- a/activerecord/test/associations_join_model_test.rb
+++ b/activerecord/test/associations_join_model_test.rb
@@ -231,11 +231,11 @@ class AssociationsJoinModelTest < Test::Unit::TestCase
end
def test_has_many_through_has_many_find_all
- assert_equal comments(:greetings), authors(:david).comments.find(:all).first
+ assert_equal comments(:greetings), authors(:david).comments.find(:all, :order => 'comments.id').first
end
def test_has_many_through_has_many_find_first
- assert_equal comments(:greetings), authors(:david).comments.find(:first)
+ assert_equal comments(:greetings), authors(:david).comments.find(:first, :order => 'comments.id')
end
def test_has_many_through_has_many_find_conditions
@@ -246,6 +246,14 @@ class AssociationsJoinModelTest < Test::Unit::TestCase
assert_equal comments(:more_greetings), authors(:david).comments.find(2)
end
+ def test_eager_load_has_many_through_has_many
+ author = Author.find :first, :conditions => ['name = ?', 'David'], :include => :comments, :order => 'comments.id'
+ SpecialComment.new; VerySpecialComment.new
+ assert_no_queries do
+ assert_equal [1,2,3,5,6,7,8,9,10], author.comments.collect(&:id)
+ end
+ end
+
private
# create dynamic Post models to allow different dependency options
def find_post_with_dependency(post_id, association, association_name, dependency)