File tree Expand file tree Collapse file tree 4 files changed +30
-6
lines changed Expand file tree Collapse file tree 4 files changed +30
-6
lines changed Original file line number Diff line number Diff line change
1
+ ## Unreleased
2
+
3
+ * Fix a regression in which autoload paths were initialized too late.
4
+
5
+ * Xavier Noria*
6
+
1
7
## Rails 7.0.0.alpha2 (September 15, 2021) ##
2
8
3
9
* Fix activestorage dependency in the npm package.
Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ module Bootstrap
66
66
67
67
# We setup the once autoloader this early so that engines and applications
68
68
# are able to autoload from these paths during initialization.
69
- initializer :setup_once_autoloader do
69
+ initializer :setup_once_autoloader , after : :set_eager_load_paths , before : :bootstrap_hook do
70
70
autoloader = Rails . autoloaders . once
71
71
72
72
ActiveSupport ::Dependencies . autoload_once_paths . freeze
Original file line number Diff line number Diff line change @@ -570,14 +570,12 @@ def load_seed
570
570
$LOAD_PATH. uniq!
571
571
end
572
572
573
- initializer :set_autoload_once_paths , before : :setup_once_autoloader do
574
- config . autoload_once_paths . freeze
573
+ initializer :set_autoload_paths , before : :bootstrap_hook do
574
+ ActiveSupport :: Dependencies . autoload_paths . unshift ( * _all_autoload_paths )
575
575
ActiveSupport ::Dependencies . autoload_once_paths . unshift ( *_all_autoload_once_paths )
576
- end
577
576
578
- initializer :set_autoload_paths , before : :setup_main_autoloader do
579
577
config . autoload_paths . freeze
580
- ActiveSupport :: Dependencies . autoload_paths . unshift ( * _all_autoload_paths )
578
+ config . autoload_once_paths . freeze
581
579
end
582
580
583
581
initializer :set_eager_load_paths , before : :bootstrap_hook do
Original file line number Diff line number Diff line change @@ -233,6 +233,26 @@ class AddFirstNameToUsers < ActiveRecord::Migration::Current
233
233
assert_equal "Another" , Another . name
234
234
end
235
235
236
+ test "when the bootstrap hook runs, autoload paths are set" do
237
+ $test_autoload_once_paths = [ ]
238
+ $test_autoload_paths = [ ]
239
+
240
+ add_to_config <<~RUBY
241
+ # Unrealistic configuration, but keeps the test simple.
242
+ config.autoload_once_paths << "#{ app_path } /app/helpers"
243
+
244
+ initializer "inspect autoload paths", after: :bootstrap_hook do
245
+ $test_autoload_once_paths += ActiveSupport::Dependencies.autoload_once_paths
246
+ $test_autoload_paths += ActiveSupport::Dependencies.autoload_paths
247
+ end
248
+ RUBY
249
+
250
+ boot_rails
251
+
252
+ assert_includes $test_autoload_once_paths, "#{ app_path } /app/helpers"
253
+ assert_includes $test_autoload_paths, "#{ app_path } /app/controllers"
254
+ end
255
+
236
256
test "puts its models directory on autoload path" do
237
257
@plugin . write "app/models/my_bukkit.rb" , "class MyBukkit ; end"
238
258
boot_rails
You can’t perform that action at this time.
0 commit comments