diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-05 18:43:56 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-05 18:43:56 +0000 |
commit | 4f00c70580e376691bd1d6c1f9d09efbaa7bf9c9 (patch) | |
tree | 23865027d66ca498ad6c63c5cbb997ee85dc41d0 /activerecord/test/associations_join_model_test.rb | |
parent | 84b8920a11985a771e6dbddbf5ed4e3852a2e790 (diff) | |
download | rails-4f00c70580e376691bd1d6c1f9d09efbaa7bf9c9.tar.gz rails-4f00c70580e376691bd1d6c1f9d09efbaa7bf9c9.tar.bz2 rails-4f00c70580e376691bd1d6c1f9d09efbaa7bf9c9.zip |
Fixed eager loading problems with single-table inheritance [Rick Olson] Added smarter table aliasing for eager associations for multiple self joins [Rick Olson] (closes #3580)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3776 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/associations_join_model_test.rb')
-rw-r--r-- | activerecord/test/associations_join_model_test.rb | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/activerecord/test/associations_join_model_test.rb b/activerecord/test/associations_join_model_test.rb index a2f42f060e..b14693d7a6 100644 --- a/activerecord/test/associations_join_model_test.rb +++ b/activerecord/test/associations_join_model_test.rb @@ -81,7 +81,34 @@ class AssociationsJoinModelTest < Test::Unit::TestCase def test_has_many_with_piggyback assert_equal "2", categories(:sti_test).authors.first.post_id.to_s end - + + def test_include_has_many_through + posts = Post.find(:all, :order => 'posts.id') + posts_with_authors = Post.find(:all, :include => :authors, :order => 'posts.id') + assert_equal posts.length, posts_with_authors.length + posts.length.times do |i| + assert_equal posts[i].authors.length, assert_no_queries { posts_with_authors[i].authors.length } + end + end + + def test_include_polymorphic_has_many_through + posts = Post.find(:all, :order => 'posts.id') + posts_with_tags = Post.find(:all, :include => :tags, :order => 'posts.id') + assert_equal posts.length, posts_with_tags.length + posts.length.times do |i| + assert_equal posts[i].tags.length, assert_no_queries { posts_with_tags[i].tags.length } + end + end + + def test_include_polymorphic_has_many + posts = Post.find(:all, :order => 'posts.id') + posts_with_taggings = Post.find(:all, :include => :taggings, :order => 'posts.id') + assert_equal posts.length, posts_with_taggings.length + posts.length.times do |i| + assert_equal posts[i].taggings.length, assert_no_queries { posts_with_taggings[i].taggings.length } + end + end + def test_has_many_find_all assert_equal [categories(:general)], authors(:david).categories.find(:all) end |