mirror of
https://github.com/github/rails.git
synced 2026-01-30 00:38:00 -05:00
Fixed that default timezones for new / initialize should uphold utc setting (closes #5709) [daniluk@yahoo.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4670 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -1996,7 +1996,7 @@ module ActiveRecord #:nodoc:
|
||||
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
|
||||
|
||||
@@ -560,6 +560,22 @@ class BasicsTest < Test::Unit::TestCase
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user