diff options
author | Daniel Neighman <has.sox@gmail.com> | 2010-04-22 09:43:33 +1000 |
---|---|---|
committer | wycats <wycats@gmail.com> | 2010-04-21 16:54:33 -0700 |
commit | 726b5d79845c0ef50db64e2991bfec4e108faf4d (patch) | |
tree | 27fc030105d495bb7b401e5993e16893b8023fa1 /activesupport/test/core_ext | |
parent | b73177a0954aed11543f2bb829cd07cc12d4f590 (diff) | |
download | rails-726b5d79845c0ef50db64e2991bfec4e108faf4d.tar.gz rails-726b5d79845c0ef50db64e2991bfec4e108faf4d.tar.bz2 rails-726b5d79845c0ef50db64e2991bfec4e108faf4d.zip |
updates String#to_(date|date_time|time) to return nil for blank strings
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/string_ext_test.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index 58ca215970..97b08da0e4 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -117,17 +117,20 @@ class StringInflectionsTest < Test::Unit::TestCase assert_equal Time.local(2005, 2, 27, 23, 50, 19, 275038), "2005-02-27T23:50:19.275038".to_time(:local) assert_equal DateTime.civil(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_time assert_equal Time.local_time(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_time(:local) + assert_equal nil, "".to_time end - + def test_string_to_datetime assert_equal DateTime.civil(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_datetime assert_equal 0, "2039-02-27 23:50".to_datetime.offset # use UTC offset assert_equal ::Date::ITALY, "2039-02-27 23:50".to_datetime.start # use Ruby's default start value assert_equal DateTime.civil(2039, 2, 27, 23, 50, 19 + Rational(275038, 1000000), "-04:00"), "2039-02-27T23:50:19.275038-04:00".to_datetime + assert_equal nil, "".to_datetime end - + def test_string_to_date assert_equal Date.new(2005, 2, 27), "2005-02-27".to_date + assert_equal nil, "".to_date end def test_access @@ -255,7 +258,7 @@ end string.rb - Interpolation for String. Copyright (C) 2005-2009 Masao Mutoh - + You may redistribute it and/or modify it under the same license terms as Ruby. =end |