aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/type/date_test.rb
blob: 44e20a327b5431029530156805ba01210b17cbb9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require "cases/helper"
require "active_model/type"

module ActiveModel
  module Type
    class DateTest < ActiveModel::TestCase
      def test_type_cast_date
        type = Type::Date.new
        assert_equal nil, type.cast(nil)
        assert_equal nil, type.cast("")
        assert_equal nil, type.cast(" ")
        assert_equal nil, type.cast("ABC")

        date_string = ::Time.now.utc.strftime("%F")
        assert_equal date_string, type.cast(date_string).strftime("%F")
      end
    end
  end
end