diff options
-rw-r--r-- | actionpack/lib/sprockets/railtie.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/application.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/engine.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/initializable.rb | 5 | ||||
-rw-r--r-- | railties/test/initializable_test.rb | 4 |
5 files changed, 8 insertions, 7 deletions
diff --git a/actionpack/lib/sprockets/railtie.rb b/actionpack/lib/sprockets/railtie.rb index 6b67fb1d2d..6e93bd3035 100644 --- a/actionpack/lib/sprockets/railtie.rb +++ b/actionpack/lib/sprockets/railtie.rb @@ -14,7 +14,7 @@ module Sprockets load "sprockets/assets.rake" end - initializer "sprockets.environment", :group => :assets do |app| + initializer "sprockets.environment", :group => :all do |app| config = app.config next unless config.assets.enabled diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 2e412147d3..cbb2d23238 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -91,7 +91,7 @@ module Rails @routes_reloader ||= RoutesReloader.new end - def initialize!(group=nil) + def initialize!(group=:default) raise "Application has been already initialized." if @initialized run_initializers(group, self) @initialized = true diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 0e1e719596..2d25273050 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -542,7 +542,7 @@ module Rails require environment if environment end - initializer :append_assets_path, :group => :assets do |app| + initializer :append_assets_path, :group => :all do |app| app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories) app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories) app.config.assets.paths.unshift(*paths["app/assets"].existent_directories) diff --git a/railties/lib/rails/initializable.rb b/railties/lib/rails/initializable.rb index 4c1da0a5a5..04d5b55c69 100644 --- a/railties/lib/rails/initializable.rb +++ b/railties/lib/rails/initializable.rb @@ -10,6 +10,7 @@ module Rails attr_reader :name, :block def initialize(name, context, options, &block) + options[:group] ||= :default @name, @context, @options, @block = name, context, options, block end @@ -48,10 +49,10 @@ module Rails end end - def run_initializers(group=nil, *args) + def run_initializers(group=:default, *args) return if instance_variable_defined?(:@ran) initializers.tsort.each do |initializer| - initializer.run(*args) if group.nil? || initializer.belongs_to?(group) + initializer.run(*args) if initializer.belongs_to?(group) end @ran = true end diff --git a/railties/test/initializable_test.rb b/railties/test/initializable_test.rb index 1dbcc249ab..c84c7f204c 100644 --- a/railties/test/initializable_test.rb +++ b/railties/test/initializable_test.rb @@ -209,7 +209,7 @@ module InitializableTests $arr = [] instance = Instance.new instance.run_initializers - assert_equal [1, 2, 3, 4], $arr + assert_equal [2, 3, 4], $arr end test "running locals with groups" do @@ -223,7 +223,7 @@ module InitializableTests class WithArgsTest < ActiveSupport::TestCase test "running initializers with args" do $with_arg = nil - WithArgs.new.run_initializers(nil, 'foo') + WithArgs.new.run_initializers(:default, 'foo') assert_equal 'foo', $with_arg end end |