diff options
author | shtirlic <serg@podtynnyi.com> | 2011-07-11 18:41:04 +0400 |
---|---|---|
committer | shtirlic <serg@podtynnyi.com> | 2011-07-11 18:41:04 +0400 |
commit | c2b79c011f4ec39426c93812ab58660718c7cb92 (patch) | |
tree | 63e81f4f4565c95b2ebd9b8e7597abea16ba1ab9 /activesupport/test | |
parent | 539d684b7a063555bd2d03a36b2e778217d94ae9 (diff) | |
download | rails-c2b79c011f4ec39426c93812ab58660718c7cb92.tar.gz rails-c2b79c011f4ec39426c93812ab58660718c7cb92.tar.bz2 rails-c2b79c011f4ec39426c93812ab58660718c7cb92.zip |
Fix xmlschema output with fraction_digits >0
Current implementation produce incorrect output when Time#usec returns
integer < 100000, because to_s doesn't add leading zeros.
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/time_with_zone_test.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb index 72b55183ba..b2309ae806 100644 --- a/activesupport/test/core_ext/time_with_zone_test.rb +++ b/activesupport/test/core_ext/time_with_zone_test.rb @@ -111,6 +111,13 @@ class TimeWithZoneTest < Test::Unit::TestCase assert_equal "1999-12-31T19:00:00.123456-05:00", @twz.xmlschema(12) end + def test_xmlschema_with_fractional_seconds_lower_than_hundred_thousand + @twz += 0.001234 # advance the time by a fraction + assert_equal "1999-12-31T19:00:00.001-05:00", @twz.xmlschema(3) + assert_equal "1999-12-31T19:00:00.001234-05:00", @twz.xmlschema(6) + assert_equal "1999-12-31T19:00:00.001234-05:00", @twz.xmlschema(12) + end + def test_to_yaml assert_match(/^--- 2000-01-01 00:00:00(\.0+)?\s*Z\n/, @twz.to_yaml) end |