Skip to content

Commit

Permalink
Add test case for issue rails#13437
Browse files Browse the repository at this point in the history
(Preload/includes with multiple arguments fails in certain conditions)
  • Loading branch information
khustochka committed Dec 24, 2013
1 parent df09ce9 commit 9d6035f
Showing 1 changed file with 14 additions and 0 deletions.
Expand Up @@ -33,6 +33,20 @@ def test_eager_association_loading_with_cascaded_two_levels_and_one_level
assert_equal 2, authors[1].categorizations.size
end

def test_eager_association_loading_with_cascaded_interdependent_one_level_and_two_levels
authors_relation = Author.all.merge!(:includes=>[:comments, {:posts=>:categorizations}], :order=>"authors.id")
assert_nothing_raised do
authors_relation.to_a
end
authors = authors_relation.to_a
assert_equal 3, authors.size
assert_equal 10, authors[0].comments.size
assert_equal 1, authors[1].comments.size
assert_equal 5, authors[0].posts.size
assert_equal 3, authors[1].posts.size
assert_equal 3, authors[0].posts.collect{|post| post.categorizations.size }.inject(0){|sum,i| sum+i}
end

def test_eager_association_loading_with_hmt_does_not_table_name_collide_when_joining_associations
assert_nothing_raised do
Author.joins(:posts).eager_load(:comments).where(:posts => {:taggings_count => 1}).to_a
Expand Down

0 comments on commit 9d6035f

Please sign in to comment.