diff options
author | Iain Beeston <iain.beeston@gmail.com> | 2016-10-14 17:21:11 +0100 |
---|---|---|
committer | Iain Beeston <iain.beeston@gmail.com> | 2016-10-15 07:33:22 +0100 |
commit | 894c033843fe93f50bfe47c98a77bb3183988d09 (patch) | |
tree | 73f33f6ffe8d55b5cbe3ea538ce349b075b2c3fb /activemodel/test/cases/type/time_test.rb | |
parent | 159b774887cfb3d5c862b2b48d24d75b658e47af (diff) | |
download | rails-894c033843fe93f50bfe47c98a77bb3183988d09.tar.gz rails-894c033843fe93f50bfe47c98a77bb3183988d09.tar.bz2 rails-894c033843fe93f50bfe47c98a77bb3183988d09.zip |
Refactored ActiveModel::Type tests into their own files
Diffstat (limited to 'activemodel/test/cases/type/time_test.rb')
-rw-r--r-- | activemodel/test/cases/type/time_test.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/activemodel/test/cases/type/time_test.rb b/activemodel/test/cases/type/time_test.rb new file mode 100644 index 0000000000..a6a79833e6 --- /dev/null +++ b/activemodel/test/cases/type/time_test.rb @@ -0,0 +1,21 @@ +require "cases/helper" +require "active_model/type" + +module ActiveModel + module Type + class TimeTest < ActiveModel::TestCase + def test_type_cast_time + type = Type::Time.new + assert_equal nil, type.cast(nil) + assert_equal nil, type.cast("") + assert_equal nil, type.cast("ABC") + + time_string = ::Time.now.utc.strftime("%T") + assert_equal time_string, type.cast(time_string).strftime("%T") + + assert_equal ::Time.utc(2000, 1, 1, 16, 45, 54), type.cast("2015-06-13T19:45:54+03:00") + assert_equal ::Time.utc(1999, 12, 31, 21, 7, 8), type.cast("06:07:08+09:00") + end + end + end +end |