提交 e2b71e9f 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #25834 from...

Merge pull request #25834 from alpaca-tc/fixes_multiparameter_attributes_on_time_with_time_zone_aware_attributes

Fix bug in method AR TimeZoneConverter#set_time_zone_without_conversion
* Fixes multi-parameter attributes conversion with invalid params.
*Hiroyuki Ishii*
* Add newline between each migration in `structure.sql`.
Keeps schema migration inserts as a single commit, but allows for easier
......
......@@ -39,7 +39,7 @@ def convert_time_to_time_zone(value)
end
def set_time_zone_without_conversion(value)
::Time.zone.local_to_utc(value).in_time_zone
::Time.zone.local_to_utc(value).in_time_zone if value
end
def map_avoiding_infinite_recursion(value)
......
......@@ -202,6 +202,20 @@ def test_multiparameter_attributes_on_time_with_time_zone_aware_attributes
Topic.reset_column_information
end
def test_multiparameter_attributes_on_time_with_time_zone_aware_attributes_and_invalid_time_params
with_timezone_config aware_attributes: true do
Topic.reset_column_information
attributes = {
"written_on(1i)" => "2004", "written_on(2i)" => "", "written_on(3i)" => ""
}
topic = Topic.find(1)
topic.attributes = attributes
assert_nil topic.written_on
end
ensure
Topic.reset_column_information
end
def test_multiparameter_attributes_on_time_with_time_zone_aware_attributes_false
with_timezone_config default: :local, aware_attributes: false, zone: -28800 do
attributes = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册