From 562cebac362e2759eeed93c6c0ba1c1cd725961c Mon Sep 17 00:00:00 2001 From: Anatoliy Lysenko Date: Wed, 20 Oct 2010 08:45:34 +0300 Subject: [PATCH 1/2] Test count with cascaded eager loading with joins. --- .../associations/cascaded_eager_loading_test.rb | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/activerecord/test/cases/associations/cascaded_eager_loading_test.rb b/activerecord/test/cases/associations/cascaded_eager_loading_test.rb index c7c32da..e0a5f15 100644 --- a/activerecord/test/cases/associations/cascaded_eager_loading_test.rb +++ b/activerecord/test/cases/associations/cascaded_eager_loading_test.rb @@ -45,6 +45,12 @@ class CascadedEagerLoadingTest < ActiveRecord::TestCase assert_equal people(:michael), Person.eager_load(:primary_contact => :primary_contact).where('primary_contacts_people_2.first_name = ?', 'Susan').order('people.id').first end + def test_cascaded_eager_association_loading_with_join_for_count + categories = Category.joins(:categorizations).includes([{:posts=>:comments}, :authors]) + + assert_nothing_raised { categories.count } + end + def test_eager_association_loading_with_join_for_count authors = Author.joins(:special_posts).includes([:posts, :categorizations]) -- 1.7.0.4 From ad769ae1d573ab9bfb4cabe313fba67492327003 Mon Sep 17 00:00:00 2001 From: Anatoliy Lysenko Date: Sat, 23 Oct 2010 12:55:59 +0300 Subject: [PATCH 2/2] Test cascaded eager loading with including the same association two times. --- .../associations/cascaded_eager_loading_test.rb | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/activerecord/test/cases/associations/cascaded_eager_loading_test.rb b/activerecord/test/cases/associations/cascaded_eager_loading_test.rb index e0a5f15..5cc42a8 100644 --- a/activerecord/test/cases/associations/cascaded_eager_loading_test.rb +++ b/activerecord/test/cases/associations/cascaded_eager_loading_test.rb @@ -2,6 +2,7 @@ require "cases/helper" require 'models/post' require 'models/comment' require 'models/author' +require 'models/category' require 'models/categorization' require 'models/company' require 'models/topic' @@ -45,6 +46,12 @@ class CascadedEagerLoadingTest < ActiveRecord::TestCase assert_equal people(:michael), Person.eager_load(:primary_contact => :primary_contact).where('primary_contacts_people_2.first_name = ?', 'Susan').order('people.id').first end + def test_cascaded_eager_association_loading_with_twice_includes + categories = Category.includes(:posts).includes({:posts=>:comments}).where("posts.id is not null") + assert_nothing_raised { categories.count } + assert_nothing_raised { categories.all } + end + def test_cascaded_eager_association_loading_with_join_for_count categories = Category.joins(:categorizations).includes([{:posts=>:comments}, :authors]) -- 1.7.0.4