From 7b2dfdeab6e4ef096e4dc1fe313056f08ccf7dc5 Mon Sep 17 00:00:00 2001 From: Lisa Ugray Date: Tue, 4 Jul 2017 14:22:35 -0400 Subject: Fix `ActiveModel::Type::DateTime#serialize` `ActiveModel::Type::DateTime#serialize` should return a `Time` object so that finding by a datetime column works correctly. --- activerecord/test/cases/date_time_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'activerecord') diff --git a/activerecord/test/cases/date_time_test.rb b/activerecord/test/cases/date_time_test.rb index ad7da9de70..6cd98fe254 100644 --- a/activerecord/test/cases/date_time_test.rb +++ b/activerecord/test/cases/date_time_test.rb @@ -58,4 +58,17 @@ class DateTimeTest < ActiveRecord::TestCase assert_equal now, task.starting end end + + def test_date_time_with_string_value_with_subsecond_precision + skip unless subsecond_precision_supported? + string_value = "2017-07-04 14:19:00.5" + topic = Topic.create(written_on: string_value) + assert_equal topic, Topic.find_by(written_on: string_value) + end + + def test_date_time_with_string_value_with_non_iso_format + string_value = "04/07/2017 2:19pm" + topic = Topic.create(written_on: string_value) + assert_equal topic, Topic.find_by(written_on: string_value) + end end -- cgit v1.2.3