Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

:group => :assets should only run in the assets environment.

  • Loading branch information...
commit d68884f4fddf5452f1dcbdf1a7b35d5889926fe5 1 parent ac1fc5c
@josevalim josevalim authored
View
2  actionpack/lib/sprockets/railtie.rb
@@ -14,7 +14,7 @@ class Railtie < ::Rails::Railtie
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
View
2  railties/lib/rails/application.rb
@@ -91,7 +91,7 @@ def routes_reloader
@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
View
2  railties/lib/rails/engine.rb
@@ -542,7 +542,7 @@ def load_seed
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)
View
5 railties/lib/rails/initializable.rb
@@ -10,6 +10,7 @@ class Initializer
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 @@ def +(other)
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
View
4 railties/test/initializable_test.rb
@@ -209,7 +209,7 @@ class InstanceTest < ActiveSupport::TestCase
$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 @@ class InstanceTest < ActiveSupport::TestCase
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
Please sign in to comment.
Something went wrong with that request. Please try again.