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_cascaded_eager_loading_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_cascaded_eager_loading_test.rb')
-rw-r--r-- | activerecord/test/associations_cascaded_eager_loading_test.rb | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/activerecord/test/associations_cascaded_eager_loading_test.rb b/activerecord/test/associations_cascaded_eager_loading_test.rb index 797bc85bc3..8f0a41f593 100644 --- a/activerecord/test/associations_cascaded_eager_loading_test.rb +++ b/activerecord/test/associations_cascaded_eager_loading_test.rb @@ -56,23 +56,33 @@ class CascadedEagerLoadingTest < Test::Unit::TestCase def test_eager_association_loading_with_acts_as_tree roots = TreeMixin.find(:all, :include=>"children", :conditions=>"mixins.parent_id IS NULL", :order=>"mixins.id") assert_equal [mixins(:tree_1), mixins(:tree2_1), mixins(:tree3_1)], roots - assert_equal 2, roots[0].children.size - assert_equal 0, roots[1].children.size - assert_equal 0, roots[2].children.size + assert_no_queries do + assert_equal 2, roots[0].children.size + assert_equal 0, roots[1].children.size + assert_equal 0, roots[2].children.size + end end def test_eager_association_loading_with_cascaded_three_levels_by_ping_pong firms = Firm.find(:all, :include=>{:account=>{:firm=>:account}}, :order=>"companies.id") assert_equal 2, firms.size assert_equal firms.first.account, firms.first.account.firm.account - assert_equal companies(:first_firm).account, firms.first.account.firm.account - assert_equal companies(:first_firm).account.firm.account, firms.first.account.firm.account + assert_equal companies(:first_firm).account, assert_no_queries { firms.first.account.firm.account } + assert_equal companies(:first_firm).account.firm.account, assert_no_queries { firms.first.account.firm.account } end - def test_eager_association_loading_with_sti + def test_eager_association_loading_with_has_many_sti topics = Topic.find(:all, :include => :replies, :order => 'topics.id') assert_equal [topics(:first), topics(:second)], topics - assert_equal 1, topics[0].replies.size - assert_equal 0, topics[1].replies.size + assert_no_queries do + assert_equal 1, topics[0].replies.size + assert_equal 0, topics[1].replies.size + end + end + + def test_eager_association_loading_with_belongs_to_sti + replies = Reply.find(:all, :include => :topic, :order => 'topics.id') + assert_equal [topics(:second)], replies + assert_equal topics(:first), assert_no_queries { replies.first.topic } end end |