Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def test_eager_with_multiple_associations_with_same_table_has_many_and_habtm
- # Eager includes of has many and habtm associations aren't necessarily sorted in the same way
- # Test regular association, association with conditions, association with
- # STI, and association with conditions assured not to be true
- post_types = [:posts, :other_posts, :special_posts]
- # test both has_many and has_and_belongs_to_many
- [Author, Category].each do |className|
- d1 = find_all_ordered(className)
- # test including all post types at once
- d2 = find_all_ordered(className, post_types)
- d1.each_index do |i|
- assert_equal(d1[i], d2[i])
- assert_equal_after_sort(d1[i].posts, d2[i].posts)
- post_types[1..-1].each do |post_type|
- # test including post_types together
- d3 = find_all_ordered(className, [:posts, post_type])
- assert_equal(d1[i], d3[i])
- assert_equal_after_sort(d1[i].posts, d3[i].posts)
- assert_equal_after_sort(d1[i].send(post_type), d2[i].send(post_type), d3[i].send(post_type))
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment