From a01c41d39efae7806f0ad3718e5d46b0c7605ac6 Mon Sep 17 00:00:00 2001 From: Eric Cohen Date: Mon, 13 Sep 2010 15:01:30 +0300 Subject: [PATCH] Failing tests. --- activerecord/test/cases/associations/eager_test.rb | 35 ++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index 1870f97..b9f479e 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -79,6 +79,41 @@ class EagerAssociationTest < ActiveRecord::TestCase assert posts.first.comments.include?(comments(:greetings)) end + def test_loading_with_includes_on_has_one_association + aa = AuthorAddress.find(1, :include => {:author => :posts}) + assert_equal aa.author.posts.count, aa.author.posts.length + end + + def test_loading_with_includes_on_has_one_association_and_order + aa = AuthorAddress.find(1, :include => {:author => :posts}, :order => "author_addresses.id") + assert_equal aa.author.posts.count, aa.author.posts.length + end + + def test_loading_with_includes_on_has_one_association_and_order_in_first_associated_table + aa = AuthorAddress.find(1, :include => {:author => :posts}, :order => "authors.id") + assert_equal aa.author.posts.count, aa.author.posts.length + end + + def test_loading_with_includes_on_has_one_association_and_order_in_second_associated_table + aa = AuthorAddress.find(1, :include => {:author => :posts}, :order => "posts.id") + assert_equal aa.author.posts.count, aa.author.posts.length + end + + def test_loading_with_includes_on_has_one_association_and_conditions + aa = AuthorAddress.find(1, :include => {:author => :posts}, :conditions => "author_addresses.id > 0") + assert_equal aa.author.posts.count, aa.author.posts.length + end + + def test_loading_with_includes_on_has_one_association_and_conditions_in_first_associated_table + aa = AuthorAddress.find(1, :include => {:author => :posts}, :conditions => "authors.id > 0") + assert_equal aa.author.posts.count, aa.author.posts.length + end + + def test_loading_with_includes_on_has_one_association_and_conditions_in_second_associated_table + aa = AuthorAddress.find(1, :include => {:author => :posts}, :conditions => "posts.id > 0") + assert_equal aa.author.posts.count, aa.author.posts.length + end + def test_duplicate_middle_objects comments = Comment.find :all, :conditions => 'post_id = 1', :include => [:post => :author] assert_no_queries do -- 1.7.1