aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-09-21 10:09:29 -0600
committerSean Griffin <sean@seantheprogrammer.com>2015-09-21 10:12:31 -0600
commit858a7b04291b447edc541c6e17eec81f0cce34e5 (patch)
tree173a80a90c6f8a46010943421e874724427a62f6 /activemodel/lib
parent4590d7729e241cb7f66e018a2a9759cb3baa36e5 (diff)
downloadrails-858a7b04291b447edc541c6e17eec81f0cce34e5.tar.gz
rails-858a7b04291b447edc541c6e17eec81f0cce34e5.tar.bz2
rails-858a7b04291b447edc541c6e17eec81f0cce34e5.zip
Move the appropriate type tests to the Active Model suite
Any tests for a type which is not overridden by Active Record, and does not test the specifics of the attributes API interacting in more complex ways have no reason to be in the Active Record suite. Doing this revealed that the implementation of the date and time types in AM was actually completely broken, and incapable of returning any value other than `nil`.
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/type/helpers/time_value.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/type/helpers/time_value.rb b/activemodel/lib/active_model/type/helpers/time_value.rb
index c55bb1e136..0a0e58654b 100644
--- a/activemodel/lib/active_model/type/helpers/time_value.rb
+++ b/activemodel/lib/active_model/type/helpers/time_value.rb
@@ -1,3 +1,5 @@
+require "active_support/core_ext/time/zones"
+
module ActiveModel
module Type
module Helpers
@@ -21,11 +23,15 @@ module ActiveModel
end
def is_utc?
- ::Time.zone_default =~ 'UTC'
+ ::Time.zone_default.nil? || ::Time.zone_default =~ 'UTC'
end
def default_timezone
- ::Time.zone_default
+ if is_utc?
+ :utc
+ else
+ :local
+ end
end
def type_cast_for_schema(value)