aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/type
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-02-18 16:04:47 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-02-18 16:04:47 +0900
commit4ea067017ae52d4a74335ed85df085a86663d213 (patch)
tree413f68bdb6283f455b788400a5e45d6ea86024d9 /activemodel/test/cases/type
parent1dfd01475d93b8801df0a2933094b437a607e3e2 (diff)
parenteb73dfc0677cb5b3a0f559020fe5d7df556056b4 (diff)
downloadrails-4ea067017ae52d4a74335ed85df085a86663d213.tar.gz
rails-4ea067017ae52d4a74335ed85df085a86663d213.tar.bz2
rails-4ea067017ae52d4a74335ed85df085a86663d213.zip
Merge pull request #29651 from Sayanc93/return-correct-date
Return correct date in ActiveModel for time to date conversions
Diffstat (limited to 'activemodel/test/cases/type')
-rw-r--r--activemodel/test/cases/type/date_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activemodel/test/cases/type/date_test.rb b/activemodel/test/cases/type/date_test.rb
index 9a393286b7..2dd1a55616 100644
--- a/activemodel/test/cases/type/date_test.rb
+++ b/activemodel/test/cases/type/date_test.rb
@@ -18,6 +18,17 @@ module ActiveModel
assert_equal date_string, type.cast(date_string).strftime("%F")
assert_equal date_string, type.cast(values_hash).strftime("%F")
end
+
+ def test_returns_correct_year
+ type = Type::Date.new
+
+ time = ::Time.utc(1, 1, 1)
+ date = ::Date.new(time.year, time.mon, time.mday)
+
+ values_hash_for_multiparameter_assignment = { 1 => 1, 2 => 1, 3 => 1 }
+
+ assert_equal date, type.cast(values_hash_for_multiparameter_assignment)
+ end
end
end
end