Fixed to_xml with :include misbehaviors when invoked on array of model...

Fixed to_xml with :include misbehaviors when invoked on array of model instances (closes #5690) [alexkwolfe@gmail.com]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4652 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 8085cbfd
*SVN*
* Fixed to_xml with :include misbehaviors when invoked on array of model instances #5690 [alexkwolfe@gmail.com]
* Added support for conditions on Base.exists? #5689 [josh@joshpeek.com]. Examples:
assert (Topic.exists?(:author_name => "David"))
......
......@@ -199,6 +199,8 @@ def add_includes
end
end
end
options[:include] = include_associations
end
end
......
......@@ -1299,6 +1299,19 @@ def test_to_xml_including_has_many_association
assert xml.include?(%(<replies><reply>))
assert xml.include?(%(<title>The Second Topic's of the day</title>))
end
def test_array_to_xml_including_has_one_association
xml = [ companies(:first_firm), companies(:rails_core) ].to_xml(:indent => 0, :skip_instruct => true, :include => :account)
assert xml.include?(companies(:first_firm).account.to_xml(:indent => 0, :skip_instruct => true))
assert xml.include?(companies(:rails_core).account.to_xml(:indent => 0, :skip_instruct => true))
end
def test_array_to_xml_including_belongs_to_association
xml = [ companies(:first_client), companies(:second_client), companies(:another_client) ].to_xml(:indent => 0, :skip_instruct => true, :include => :firm)
assert xml.include?(companies(:first_client).to_xml(:indent => 0, :skip_instruct => true))
assert xml.include?(companies(:second_client).firm.to_xml(:indent => 0, :skip_instruct => true))
assert xml.include?(companies(:another_client).firm.to_xml(:indent => 0, :skip_instruct => true))
end
def test_to_xml_including_belongs_to_association
xml = companies(:first_client).to_xml(:indent => 0, :skip_instruct => true, :include => :firm)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册