diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-09-29 22:23:16 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-09-29 22:23:16 +0000 |
commit | cb978baafa68c9bb4f1311df417947249586f47d (patch) | |
tree | 7944971bef1ca0bda41eca04c5d509f2c960bbb0 /activesupport/test | |
parent | 7ac6ed893fbfe9b4d4ce0e0ef18c3fecfbd48ff4 (diff) | |
download | rails-cb978baafa68c9bb4f1311df417947249586f47d.tar.gz rails-cb978baafa68c9bb4f1311df417947249586f47d.tar.bz2 rails-cb978baafa68c9bb4f1311df417947249586f47d.zip |
Hash#to_xml supports Bignum and BigDecimal. Closes #6313.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5209 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/array_ext_test.rb | 18 | ||||
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 8 |
2 files changed, 18 insertions, 8 deletions
diff --git a/activesupport/test/core_ext/array_ext_test.rb b/activesupport/test/core_ext/array_ext_test.rb index 64c9a8b4ff..957c56c92d 100644 --- a/activesupport/test/core_ext/array_ext_test.rb +++ b/activesupport/test/core_ext/array_ext_test.rb @@ -1,4 +1,5 @@ require File.dirname(__FILE__) + '/../abstract_unit' +require 'bigdecimal' class ArrayExtToParamTests < Test::Unit::TestCase def test_string_array @@ -116,19 +117,22 @@ end class ArrayToXmlTests < Test::Unit::TestCase def test_to_xml xml = [ - { :name => "David", :age => 26 }, { :name => "Jason", :age => 31 } + { :name => "David", :age => 26, :age_in_millis => 820497600000 }, + { :name => "Jason", :age => 31, :age_in_millis => BigDecimal.new('1.0') } ].to_xml(:skip_instruct => true, :indent => 0) - assert_equal "<records><record>", xml.first(17) - assert xml.include?(%(<age type="integer">26</age>)) - assert xml.include?(%(<name>David</name>)) - assert xml.include?(%(<age type="integer">31</age>)) - assert xml.include?(%(<name>Jason</name>)) + assert_equal "<records><record>", xml.first(17), xml + assert xml.include?(%(<age type="integer">26</age>)), xml + assert xml.include?(%(<age-in-millis type="integer">820497600000</age-in-millis>)), xml + assert xml.include?(%(<name>David</name>)), xml + assert xml.include?(%(<age type="integer">31</age>)), xml + assert xml.include?(%(<age-in-millis type="numeric">1.0</age-in-millis>)), xml + assert xml.include?(%(<name>Jason</name>)), xml end def test_to_xml_with_dedicated_name xml = [ - { :name => "David", :age => 26 }, { :name => "Jason", :age => 31 } + { :name => "David", :age => 26, :age_in_millis => 820497600000 }, { :name => "Jason", :age => 31 } ].to_xml(:skip_instruct => true, :indent => 0, :root => "people") assert_equal "<people><person>", xml.first(16) diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index df4aadfbcc..020e383c1a 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -255,11 +255,12 @@ class HashToXmlTest < Test::Unit::TestCase end def test_one_level_with_types - xml = { :name => "David", :street => "Paulina", :age => 26, :moved_on => Date.new(2005, 11, 15) }.to_xml(@xml_options) + xml = { :name => "David", :street => "Paulina", :age => 26, :age_in_millis => 820497600000, :moved_on => Date.new(2005, 11, 15) }.to_xml(@xml_options) assert_equal "<person>", xml.first(8) assert xml.include?(%(<street>Paulina</street>)) assert xml.include?(%(<name>David</name>)) assert xml.include?(%(<age type="integer">26</age>)) + assert xml.include?(%(<age-in-millis type="integer">820497600000</age-in-millis>)) assert xml.include?(%(<moved-on type="date">2005-11-15</moved-on>)) end @@ -315,6 +316,7 @@ class HashToXmlTest < Test::Unit::TestCase <id type="integer">1</id> <approved type="boolean"> true </approved> <replies-count type="integer">0</replies-count> + <replies-close-in type="integer">2592000000</replies-close-in> <written-on type="date">2003-07-16</written-on> <viewed-at type="datetime">2003-07-16T09:28:00+0000</viewed-at> <content>Have a nice day</content> @@ -329,6 +331,7 @@ class HashToXmlTest < Test::Unit::TestCase :id => 1, :approved => true, :replies_count => 0, + :replies_close_in => 2592000000, :written_on => Date.new(2003, 7, 16), :viewed_at => Time.utc(2003, 7, 16, 9, 28), :content => "Have a nice day", @@ -372,6 +375,7 @@ class HashToXmlTest < Test::Unit::TestCase <id type="integer">1</id> <approved type="boolean">false</approved> <replies-count type="integer">0</replies-count> + <replies-close-in type="integer">2592000000</replies-close-in> <written-on type="date">2003-07-16</written-on> <viewed-at type="datetime">2003-07-16T09:28:00+0000</viewed-at> <content>Have a nice day</content> @@ -384,6 +388,7 @@ class HashToXmlTest < Test::Unit::TestCase <id type="integer">1</id> <approved type="boolean">false</approved> <replies-count type="integer">0</replies-count> + <replies-close-in type="integer">2592000000</replies-close-in> <written-on type="date">2003-07-16</written-on> <viewed-at type="datetime">2003-07-16T09:28:00+0000</viewed-at> <content>Have a nice day</content> @@ -399,6 +404,7 @@ class HashToXmlTest < Test::Unit::TestCase :id => 1, :approved => false, :replies_count => 0, + :replies_close_in => 2592000000, :written_on => Date.new(2003, 7, 16), :viewed_at => Time.utc(2003, 7, 16, 9, 28), :content => "Have a nice day", |