mirror of
https://github.com/github/rails.git
synced 2026-01-10 07:07:54 -05:00
do not reset associations when preloading twice.
Closes #9806. As the `through_options` always contained `{:order=>nil}` the second time, the preloader ran, the association was always reset. This patch only adds the `:order` to the `through_options` if it is set.
This commit is contained in:
@@ -1118,4 +1118,11 @@ class EagerAssociationTest < ActiveRecord::TestCase
|
||||
assert_no_queries { assert_equal 2, author.comments_with_order_and_conditions.size }
|
||||
assert_no_queries { assert_equal 5, author.posts.size, "should not cache a subset of the association" }
|
||||
end
|
||||
|
||||
test "preloading a through association twice does not reset it" do
|
||||
members = Member.includes(current_membership: :club).includes(:club).to_a
|
||||
assert_no_queries {
|
||||
assert_equal 3, members.map(&:current_membership).map(&:club).size
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user