From 817d5d489d70496de67dbff97497b35578e6491b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=BCtke?= Date: Wed, 27 Jun 2007 16:37:40 +0000 Subject: [PATCH] Add the type="array" moniker to has_many / has_and_belongs_to_many associations upon serialization. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7144 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/xml_serialization.rb | 2 +- activerecord/test/base_test.rb | 8 ++++---- activerecord/test/xml_serialization_test.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/activerecord/lib/active_record/xml_serialization.rb b/activerecord/lib/active_record/xml_serialization.rb index c3a39fc49d..df50ecc017 100644 --- a/activerecord/lib/active_record/xml_serialization.rb +++ b/activerecord/lib/active_record/xml_serialization.rb @@ -207,7 +207,7 @@ module ActiveRecord #:nodoc: tag = association.to_s tag = tag.dasherize if dasherize? - builder.tag!(tag) do + builder.tag!(tag, :type => :array) do records.each { |r| r.to_xml(opts.merge(:root=>r.class.to_s.underscore)) } end end diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index a0a6100abd..5a224bfbb8 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -1563,13 +1563,13 @@ class BasicsTest < Test::Unit::TestCase def test_to_xml_including_has_many_association xml = topics(:first).to_xml(:indent => 0, :skip_instruct => true, :include => :replies, :except => :replies_count) assert_equal "", xml.first(7) - assert xml.include?(%()) + assert xml.include?(%()) assert xml.include?(%(The Second Topic's of the day)) 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?(%()) + assert xml.include?(%()) end def test_array_to_xml_including_methods @@ -1603,7 +1603,7 @@ class BasicsTest < Test::Unit::TestCase xml = companies(:first_firm).to_xml(:indent => 0, :skip_instruct => true, :include => [ :clients, :account ]) assert_equal "", xml.first(6) assert xml.include?(%()) - assert xml.include?(%()) + assert xml.include?(%()) end def test_to_xml_including_multiple_associations_with_options @@ -1614,7 +1614,7 @@ class BasicsTest < Test::Unit::TestCase assert_equal "", xml.first(6) assert xml.include?(%(Summit)) - assert xml.include?(%()) + assert xml.include?(%()) end def test_to_xml_including_methods diff --git a/activerecord/test/xml_serialization_test.rb b/activerecord/test/xml_serialization_test.rb index b40fa0b84e..5cb40752ec 100644 --- a/activerecord/test/xml_serialization_test.rb +++ b/activerecord/test/xml_serialization_test.rb @@ -146,7 +146,7 @@ class DatabaseConnectedXmlSerializationTest < Test::Unit::TestCase def test_include_uses_association_name xml = authors(:david).to_xml :include=>:hello_posts, :indent=>0 - assert_match %r{}, xml + assert_match %r{}, xml assert_match %r{}, xml assert_match %r{}, xml end