diff options
author | Annie-Claude Côté <hello@annie.codes> | 2018-05-16 15:50:04 -0400 |
---|---|---|
committer | Annie-Claude Côté <hello@annie.codes> | 2018-05-16 17:01:07 -0400 |
commit | 6ff593ef87f0a63e41022cbb3542ff8319e5a630 (patch) | |
tree | a79e81651b1450d89d996856724f1723a562d1f2 /activerecord/test | |
parent | 35bf8e90b18954fb1ebf2b4a03a123e04634b064 (diff) | |
download | rails-6ff593ef87f0a63e41022cbb3542ff8319e5a630.tar.gz rails-6ff593ef87f0a63e41022cbb3542ff8319e5a630.tar.bz2 rails-6ff593ef87f0a63e41022cbb3542ff8319e5a630.zip |
Fix user_input_in_time_zone to coerce non valid string into nil
Before it was coercing an invalid string into "2000-01-01 00:00:00".
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/attribute_methods_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index 4a7427158a..434d32846c 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -736,6 +736,16 @@ class AttributeMethodsTest < ActiveRecord::TestCase end end + test "setting invalid string to a zone-aware time attribute" do + in_time_zone "Pacific Time (US & Canada)" do + record = @target.new + time_string = "ABC" + + record.bonus_time = time_string + assert_nil record.bonus_time + end + end + test "removing time zone-aware types" do with_time_zone_aware_types(:datetime) do in_time_zone "Pacific Time (US & Canada)" do |