diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-02-18 03:16:23 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-02-18 04:20:52 +0900 |
commit | 907280ddfd78c53e2eb5af6f12512dc38df38bd8 (patch) | |
tree | 445db778f4e92d73acec0896e068f978c7ed6383 /activemodel/test/cases | |
parent | 07346c4b35df191cfb05353a0a9f3e2f30faca65 (diff) | |
download | rails-907280ddfd78c53e2eb5af6f12512dc38df38bd8.tar.gz rails-907280ddfd78c53e2eb5af6f12512dc38df38bd8.tar.bz2 rails-907280ddfd78c53e2eb5af6f12512dc38df38bd8.zip |
Fix type cast with values hash for Date type
`value_from_multiparameter_assignment` defined by
`AcceptsMultiparameterTime` helper requires `default_timezone` method
which is defined at `TimeValue` helper.
Since `Date` type doesn't include `TimeValue`, I've extracted `Timezone`
helper to be shared by `Date`, `DateTime`, and `Time` types.
Diffstat (limited to 'activemodel/test/cases')
-rw-r--r-- | activemodel/test/cases/type/date_test.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/activemodel/test/cases/type/date_test.rb b/activemodel/test/cases/type/date_test.rb index e8cf178612..9a393286b7 100644 --- a/activemodel/test/cases/type/date_test.rb +++ b/activemodel/test/cases/type/date_test.rb @@ -12,8 +12,11 @@ module ActiveModel assert_nil type.cast(" ") assert_nil type.cast("ABC") - date_string = ::Time.now.utc.strftime("%F") + now = ::Time.now.utc + values_hash = { 1 => now.year, 2 => now.mon, 3 => now.mday } + date_string = now.strftime("%F") assert_equal date_string, type.cast(date_string).strftime("%F") + assert_equal date_string, type.cast(values_hash).strftime("%F") end end end |