aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-rw-r--r--railties/CHANGELOG.md9
-rw-r--r--railties/lib/rails/application.rb2
-rw-r--r--railties/test/railties/railtie_test.rb7
3 files changed, 16 insertions, 2 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index 70f4b84237..594d239290 100644
--- a/railties/CHANGELOG.md
+++ b/railties/CHANGELOG.md
@@ -1,3 +1,10 @@
+* Run `before_configuration` callbacks as soon as application constant
+ inherits from `Rails::Application`.
+
+ Fixes #19880.
+
+ *Yuji Yaginuma*
+
* A generated app should not include Uglifier with `--skip-javascript` option.
*Ben Pickles*
@@ -17,7 +24,7 @@
*John Meehan*
-* Display name of the class defining the initializer along with the initializer
+* Display name of the class defining the initializer along with the initializer
name in the output of `rails initializers`.
Before:
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb
index 9c150965bf..b01196e3ed 100644
--- a/railties/lib/rails/application.rb
+++ b/railties/lib/rails/application.rb
@@ -87,6 +87,7 @@ module Rails
super
Rails.app_class = base
add_lib_to_load_path!(find_root(base.called_from))
+ ActiveSupport.run_load_hooks(:before_configuration, base)
end
def instance
@@ -146,7 +147,6 @@ module Rails
def run_load_hooks! # :nodoc:
return self if @ran_load_hooks
@ran_load_hooks = true
- ActiveSupport.run_load_hooks(:before_configuration, self)
@initial_variable_values.each do |variable_name, value|
if INITIAL_VARIABLES.include?(variable_name)
diff --git a/railties/test/railties/railtie_test.rb b/railties/test/railties/railtie_test.rb
index 994019267c..755ac23cb1 100644
--- a/railties/test/railties/railtie_test.rb
+++ b/railties/test/railties/railtie_test.rb
@@ -79,6 +79,13 @@ module RailtiesTest
assert_equal app_path, $before_configuration
end
+ test "before_configuration callbacks run as soon as the application constant inherits from Rails::Application" do
+ $before_configuration = false
+ class Foo < Rails::Railtie ; config.before_configuration { $before_configuration = true } ; end
+ class Application < Rails::Application ; end
+ assert $before_configuration
+ end
+
test "railtie can add after_initialize callbacks" do
$after_initialize = false
class Foo < Rails::Railtie ; config.after_initialize { $after_initialize = true } ; end