diff options
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/CHANGELOG | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/array/conversions.rb | 4 | ||||
-rw-r--r-- | activesupport/test/core_ext/array_ext_test.rb | 10 |
3 files changed, 14 insertions, 2 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index b1747b3ed0..ac42d9c630 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed Array#to_xml when it contains a series of hashes (each piece would get its own XML declaration) #6610 [thkarcher/cyu] + * Added Time#to_s(:time) which will just return H:M, like 17:44 [DHH] * Add Module#attr_accessor_with_default to initialize value of attribute before setting it. Closes #6538. [Stuart Halloway, Marcel Molina Jr.] diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb index 1a5ddee9c6..51ac83294c 100644 --- a/activesupport/lib/active_support/core_ext/array/conversions.rb +++ b/activesupport/lib/active_support/core_ext/array/conversions.rb @@ -61,9 +61,9 @@ module ActiveSupport #:nodoc: 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 diff --git a/activesupport/test/core_ext/array_ext_test.rb b/activesupport/test/core_ext/array_ext_test.rb index 957c56c92d..709df84f06 100644 --- a/activesupport/test/core_ext/array_ext_test.rb +++ b/activesupport/test/core_ext/array_ext_test.rb @@ -169,4 +169,14 @@ class ArrayToXmlTests < Test::Unit::TestCase 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 |