diff options
author | José Valim <jose.valim@gmail.com> | 2011-10-02 22:02:12 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-10-02 22:08:33 +0200 |
commit | d68884f4fddf5452f1dcbdf1a7b35d5889926fe5 (patch) | |
tree | 34f200d7a092bad4fb0a6fb0026d8cd76d637f02 /railties | |
parent | ac1fc5c59499db8d3e875bbd76e0b7c2c9240089 (diff) | |
download | rails-d68884f4fddf5452f1dcbdf1a7b35d5889926fe5.tar.gz rails-d68884f4fddf5452f1dcbdf1a7b35d5889926fe5.tar.bz2 rails-d68884f4fddf5452f1dcbdf1a7b35d5889926fe5.zip |
:group => :assets should only run in the assets environment.
Diffstat (limited to 'railties')
-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 |
4 files changed, 7 insertions, 6 deletions
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 |