提交 3165dca2 编写于 作者: A Aaron Patterson

include_in_memory? should check against @target list in case of new records. [#6257 state:resolved]

上级 f2beb56c
......@@ -518,10 +518,10 @@ def fetch_first_or_last_using_find?(args)
def include_in_memory?(record)
if @reflection.is_a?(ActiveRecord::Reflection::ThroughReflection)
@owner.send(proxy_reflection.through_reflection.name).any? do |source|
@owner.send(proxy_reflection.through_reflection.name).any? { |source|
target = source.send(proxy_reflection.source_reflection.name)
target.respond_to?(:include?) ? target.include?(record) : target == record
end
} || @target.include?(record)
else
@target.include?(record)
end
......
......@@ -32,6 +32,13 @@ def setup
Reader.create :person_id => 0, :post_id => 0
end
def test_include?
person = Person.new
post = Post.new
person.posts << post
assert person.posts.include?(post)
end
def test_associate_existing
assert_queries(2) { posts(:thinking); people(:david) }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册