diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 550e5adb3a5d81bcd30e7b9a34036618824d420f..614cb2a1c0508076f77820c978fd3513a93608b2 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed that default timezones for new / initialize should uphold utc setting #5709 [daniluk@yahoo.com] + * Fix announcement of very long migration names. #5722 [blake@near-time.com] * The exists? class method should treat a string argument as an id rather than as conditions. #5698 [jeremy@planetargon.com] diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 40dfb387ce4eb0b1466d01a8face9ad4c0f3d41b..1d9f0175bd109e5af98f293ac93a49d88f85eb6e 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1996,7 +1996,7 @@ def execute_callstack_for_multiparameter_attributes(callstack) send(name + "=", nil) else begin - send(name + "=", Time == klass ? klass.local(*values) : klass.new(*values)) + send(name + "=", Time == klass ? (@@default_timezone == :utc ? klass.utc(*values) : klass.local(*values)) : klass.new(*values)) rescue => ex errors << AttributeAssignmentError.new("error on assignment #{values.inspect} to #{name}", ex, name) end diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index d3f2840291e2c1de5568ae808c8bba59aa3e4a4e..9518e0aca8918642617a10778b6a9d0af4f1d8b2 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -560,6 +560,22 @@ def test_utc_as_time_zone Topic.default_timezone = :local end + def test_utc_as_time_zone_and_new + # Oracle and SQLServer do not have a TIME datatype. + return true if current_adapter?(:SQLServerAdapter, :OracleAdapter) + + Topic.default_timezone = :utc + attributes = { "bonus_time(1i)"=>"2000", + "bonus_time(2i)"=>"1", + "bonus_time(3i)"=>"1", + "bonus_time(4i)"=>"10", + "bonus_time(5i)"=>"35", + "bonus_time(6i)"=>"50" } + topic = Topic.new(attributes) + assert_equal Time.utc(2000, 1, 1, 10, 35, 50), topic.bonus_time + Topic.default_timezone = :local + end + def test_default_values_on_empty_strings topic = Topic.new topic.approved = nil