diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index b711719..52a9f85 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -328,6 +328,12 @@ class EagerAssociationTest < ActiveRecord::TestCase assert_equal authors(:david), assert_no_queries { posts_with_comments_and_author.first.author } end + def test_eager_with_has_many_through_with_model_with_include_and_with_order + assert_nothing_raised do + Author.find(authors(:david).id, :include => {:posts => :tags}) + end + end + def test_eager_with_has_many_through_a_belongs_to_association author = authors(:mary) post = Post.create!(:author => author, :title => "TITLE", :body => "BODY") diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index cf69d04..daab631 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -46,7 +46,7 @@ class Post < ActiveRecord::Base has_and_belongs_to_many :special_categories, :join_table => "categories_posts", :association_foreign_key => 'category_id' has_many :taggings, :as => :taggable - has_many :tags, :through => :taggings do + has_many :tags, :through => :taggings, :order => 'tags.id' do def add_joins_and_select find :all, :select => 'tags.*, authors.id as author_id', :include => false, :joins => 'left outer join posts on taggings.taggable_id = posts.id left outer join authors on posts.author_id = authors.id'