Permalink
Browse files

Fixed Array#to_xml when it contains a series of hashes (each piece wo…

…uld get its own XML declaration) (closes #6610) [thkarcher/cyu]

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@5668 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent de3ec6c commit 2b68762f5a7a3a6cf0843101004960a0b81f84f8 @dhh dhh committed Dec 3, 2006
View
5 activesupport/CHANGELOG
@@ -1,3 +1,8 @@
+*SVN*
+
+* Fixed Array#to_xml when it contains a series of hashes (each piece would get its own XML declaration) #6610 [thkarcher/cyu]
+
+
*1.4.0 RC1* (November 22nd, 2006)
* Hash#to_xml handles keys with the same name as Kernel methods. #6613 [Catfish]
View
4 activesupport/lib/active_support/core_ext/array/conversions.rb
@@ -61,9 +61,9 @@ def to_xml(options = {})
options[:builder].instruct! unless options.delete(:skip_instruct)
- opts = options.merge({ :skip_instruct => true, :root => children })
+ opts = options.merge({ :root => children })
- options[:builder].tag!(root) { each { |e| e.to_xml(opts) } }
+ options[:builder].tag!(root) { each { |e| e.to_xml(opts.merge!({ :skip_instruct => true })) } }
end
end
View
10 activesupport/test/core_ext/array_ext_test.rb
@@ -169,4 +169,14 @@ def test_to_xml_with_dasherize_true
assert xml.include?(%(<street-address>Paulina</street-address>))
assert xml.include?(%(<street-address>Evergreen</street-address>))
end
+
+ def test_to_with_instruct
+ xml = [
+ { :name => "David", :age => 26, :age_in_millis => 820497600000 },
+ { :name => "Jason", :age => 31, :age_in_millis => BigDecimal.new('1.0') }
+ ].to_xml(:skip_instruct => false, :indent => 0)
+
+ assert /^<\?xml [^>]*/.match(xml)
+ assert xml.rindex(/<\?xml /) == 0
+ end
end

0 comments on commit 2b68762

Please sign in to comment.