diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 1990aa5261..e10980a6d9 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -427,12 +427,6 @@ module Rails end end - initializer :load_config_initializers do - paths.config.initializers.to_a.sort.each do |initializer| - load(initializer) - end - end - initializer :load_environment_config, :before => :load_environment_hook do environment = config.paths.config.environments.to_a.first require environment if environment @@ -454,6 +448,12 @@ module Rails end end + initializer :load_config_initializers do + paths.config.initializers.to_a.sort.each do |initializer| + load(initializer) + end + end + initializer :engines_blank_point do # We need this initializer so all extra initializers added in engines are # consistently executed after all the initializers above across all engines. diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index 3049011477..0cc729907e 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -55,12 +55,19 @@ module RailtiesTest initializers = Rails.application.initializers.tsort index = initializers.index { |i| i.name == "dummy_initializer" } + selection = initializers[(index-3)..(index)].map(&:name).map(&:to_s) + + assert_equal %w( + load_config_initializers + load_config_initializers + engines_blank_point + dummy_initializer + ), selection - assert index > initializers.index { |i| i.name == :load_config_initializers } - assert index > initializers.index { |i| i.name == :engines_blank_point } assert index < initializers.index { |i| i.name == :build_middleware_stack } end + class Upcaser def initialize(app) @app = app