to_xml: correct naming of included associations. Closes #5831.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4794 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jeremy Kemper 2006-08-20 14:38:58 +00:00
parent 04d2d5f288
commit edb4208857
3 changed files with 8 additions and 1 deletions

@ -1,5 +1,7 @@
*SVN*
* to_xml: correct naming of included associations. #5831 [josh.starcher@gmail.com]
* Pushing a record onto a has_many :through sets the association's foreign key to the associate's primary key and adds it to the correct association. #5815, #5829 [josh@hasmanythrough.com]
* PostgreSQL: simplify index introspection query. #5819 [stephen_purcell@yahoo.com]

@ -190,7 +190,7 @@ def add_includes
tag = tag.dasherize if dasherize?
builder.tag!(tag) do
records.each { |r| r.to_xml(opts) }
records.each { |r| r.to_xml(opts.merge(:root => association.to_s.singularize)) }
end
end
when :has_one, :belongs_to

@ -1320,6 +1320,11 @@ def test_to_xml_including_has_many_association
assert xml.include?(%(<title>The Second Topic's of the day</title>))
end
def test_array_to_xml_including_has_many_association
xml = [ topics(:first), topics(:second) ].to_xml(:indent => 0, :skip_instruct => true, :include => :replies)
assert xml.include?(%(<replies><reply>))
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))