aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-04-18 05:55:20 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-04-18 05:55:20 +0000
commit1a6954af01680d18135ce9a50ff273fd81dc6245 (patch)
tree2e2a6cf9892d5f5f785a62859ad2875ef1eefcc0 /activerecord/test
parentbceb88ef9c402a722caa7441a53f768aa14ab709 (diff)
downloadrails-1a6954af01680d18135ce9a50ff273fd81dc6245.tar.gz
rails-1a6954af01680d18135ce9a50ff273fd81dc6245.tar.bz2
rails-1a6954af01680d18135ce9a50ff273fd81dc6245.zip
Changed habtm eager loading to also use joins
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1201 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/associations_go_eager_test.rb15
-rw-r--r--activerecord/test/fixtures/posts.yml1
2 files changed, 9 insertions, 7 deletions
diff --git a/activerecord/test/associations_go_eager_test.rb b/activerecord/test/associations_go_eager_test.rb
index 0bd887478d..8de37f3d92 100644
--- a/activerecord/test/associations_go_eager_test.rb
+++ b/activerecord/test/associations_go_eager_test.rb
@@ -18,10 +18,10 @@ class EagerAssociationTest < Test::Unit::TestCase
end
def test_loading_with_multiple_associations
- posts = Post.find(:all, :include => [ :comments, :author, :categories ])
+ posts = Post.find(:all, :include => [ :comments, :author, :categories ], :order => "posts.id")
assert_equal 2, posts.first.comments.size
assert_equal 2, posts.first.categories.size
- assert_equal @greetings.body, posts.first.comments.first.body
+ assert posts.first.comments.include?(@greetings)
end
def test_loading_from_an_association
@@ -40,11 +40,12 @@ class EagerAssociationTest < Test::Unit::TestCase
end
def test_eager_association_loading_with_habtm
- posts = Post.find(:all, :include => :categories)
- assert_equal 2, posts.first.categories.size
- assert_equal 1, posts.last.categories.size
- assert_equal @technology.name, posts.first.categories.last.name
- assert_equal @general.name, posts.last.categories.first.name
+ posts = Post.find(:all, :include => :categories, :order => "posts.id")
+ assert_equal 2, posts[0].categories.size
+ assert_equal 1, posts[1].categories.size
+ assert_equal 0, posts[2].categories.size
+ assert posts[0].categories.include?(@technology)
+ assert posts[1].categories.include?(@general)
end
def test_eager_with_inheritance
diff --git a/activerecord/test/fixtures/posts.yml b/activerecord/test/fixtures/posts.yml
index 037f0a2323..decd14b70e 100644
--- a/activerecord/test/fixtures/posts.yml
+++ b/activerecord/test/fixtures/posts.yml
@@ -14,6 +14,7 @@ thinking:
authorless:
id: 3
+ author_id: 0
title: I don't have any comments
body: I just don't want to
type: Post