From e94e53f9cd70bee69759661e9771da3fe0ee9554 Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Mon, 9 Jun 2008 11:30:48 -0400 Subject: fix eager loading with dynamic finders --- .../cases/associations/has_and_belongs_to_many_associations_test.rb | 6 ++++++ .../test/cases/associations/has_many_through_associations_test.rb | 6 ++++++ 2 files changed, 12 insertions(+) (limited to 'activerecord/test/cases/associations') diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb index 294b993c55..b29df68d22 100644 --- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb @@ -681,4 +681,10 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase assert_equal developer, project.developers.find(:first) assert_equal project, developer.projects.find(:first) end + + def test_dynamic_find_should_respect_association_include + # SQL error in sort clause if :include is not included + # due to Unknown column 'authors.id' + assert Category.find(1).posts_with_authors_sorted_by_author_id.find_by_title('Welcome to the weblog') + end end diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb index 05155f6303..be5170f830 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -187,4 +187,10 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase post.people_with_callbacks.clear assert_equal (%w(Michael David Julian Roger) * 2).sort, log.last(8).collect(&:last).sort end + + def test_dynamic_find_should_respect_association_include + # SQL error in sort clause if :include is not included + # due to Unknown column 'comments.id' + assert Person.find(1).posts_with_comments_sorted_by_comment_id.find_by_title('Welcome to the weblog') + end end -- cgit v1.2.3