Permalink
Browse files

Revert "Set the default timezone after the initialization since the c…

…onfiguration"

This reverts commit 39374aa.
  • Loading branch information...
1 parent 2bca2f6 commit b45c63b8c0d8e8e92207c2d049a5d764aa12a39d @carlosantoniodasilva carlosantoniodasilva committed Jan 22, 2013
Showing with 15 additions and 27 deletions.
  1. +14 −16 activesupport/lib/active_support/railtie.rb
  2. +1 −11 railties/test/application/configuration_test.rb
View
30 activesupport/lib/active_support/railtie.rb
@@ -13,6 +13,20 @@ class Railtie < Rails::Railtie # :nodoc:
end
end
+ # Sets the default value for Time.zone
+ # If assigned value cannot be matched to a TimeZone, an exception will be raised.
+ initializer "active_support.initialize_time_zone" do |app|
+ require 'active_support/core_ext/time/zones'
+ zone_default = Time.find_zone!(app.config.time_zone)
+
+ unless zone_default
+ raise 'Value assigned to config.time_zone not recognized. ' \
+ 'Run "rake -D time" for a list of tasks for finding appropriate time zone names.'
+ end
+
+ Time.zone_default = zone_default
+ end
+
# Sets the default week start
# If assigned value is not a valid day symbol (e.g. :sunday, :monday, ...), an exception will be raised.
initializer "active_support.initialize_beginning_of_week" do |app|
@@ -28,21 +42,5 @@ class Railtie < Rails::Railtie # :nodoc:
ActiveSupport.send(k, v) if ActiveSupport.respond_to? k
end
end
-
- # Sets the default value for Time.zone after initialization since the default configuration
- # lives in application initializers.
- # If assigned value cannot be matched to a TimeZone, an exception will be raised.
- config.after_initialize do |app|
- require 'active_support/core_ext/time/zones'
- zone_default = Time.find_zone!(app.config.time_zone)
-
- unless zone_default
- raise 'Value assigned to config.time_zone not recognized. ' \
- 'Run "rake -D time" for a list of tasks for finding appropriate time zone names.'
- end
-
- Time.zone_default = zone_default
- end
-
end
end
View
12 railties/test/application/configuration_test.rb
@@ -417,17 +417,7 @@ def index
require "#{app_path}/config/environment"
- assert_equal Time.find_zone!("Wellington"), Time.zone_default
- end
-
- test "timezone can be set on initializers" do
- app_file "config/initializers/locale.rb", <<-RUBY
- Rails.application.config.time_zone = "Central Time (US & Canada)"
- RUBY
-
- require "#{app_path}/config/environment"
-
- assert_equal Time.find_zone!("Central Time (US & Canada)"), Time.zone_default
+ assert_equal "Wellington", Rails.application.config.time_zone
end
test "raises when an invalid timezone is defined in the config" do

0 comments on commit b45c63b

Please sign in to comment.