提交 a054269f 编写于 作者: S Sean Griffin

Merge Pull Request #18157

Conflicts:
	activerecord/CHANGELOG.md
* Don't raise when writing an attribute with an out-of-range datetime passed
by the user.
*Grey Baker*
* Replace deprecated `ActiveRecord::Tasks::DatabaseTasks#load_schema` with
`ActiveRecord::Tasks::DatabaseTasks#load_schema_for`.
......
......@@ -12,7 +12,11 @@ def type_cast_from_user(value)
if value.is_a?(Array)
value.map { |v| type_cast_from_user(v) }
elsif value.respond_to?(:in_time_zone)
value.in_time_zone || super
begin
value.in_time_zone || super
rescue ArgumentError
nil
end
end
end
......
......@@ -3,6 +3,8 @@
require 'models/task'
class DateTimeTest < ActiveRecord::TestCase
include InTimeZone
def test_saves_both_date_and_time
with_env_tz 'America/New_York' do
with_timezone_config default: :utc do
......@@ -29,6 +31,14 @@ def test_assign_empty_date_time
assert_nil task.ending
end
def test_assign_bad_date_time_with_timezone
in_time_zone "Pacific Time (US & Canada)" do
task = Task.new
task.starting = '2014-07-01T24:59:59GMT'
assert_nil task.starting
end
end
def test_assign_empty_date
topic = Topic.new
topic.last_read = ''
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册