aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2018-05-17 14:24:44 -0400
committerGitHub <noreply@github.com>2018-05-17 14:24:44 -0400
commit6c05728a507fe828647c2a0f62cf8ede1534a642 (patch)
treee262d714dc5d797a26dadd5997b71e1d7d586201 /activerecord
parent16c0cd187071aac89499b04e81e1006aa460bb7f (diff)
parent6ff593ef87f0a63e41022cbb3542ff8319e5a630 (diff)
downloadrails-6c05728a507fe828647c2a0f62cf8ede1534a642.tar.gz
rails-6c05728a507fe828647c2a0f62cf8ede1534a642.tar.bz2
rails-6c05728a507fe828647c2a0f62cf8ede1534a642.zip
Merge pull request #32908 from anniecodes/fix-time-random-string
Fix user_input_in_time_zone to coerce non valid string into nil
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/attribute_methods_test.rb10
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