File tree Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Original file line number Diff line number Diff line change
1
+ * Prevent unnecessary application reloads in development.
2
+
3
+ Previously, some files outside autoload paths triggered unnecessary reloads.
4
+ With this fix, application reloads according to ` Rails.autoloaders.main.dirs ` ,
5
+ thereby preventing unnecessary reloads.
6
+
7
+ * Takumasa Ochi*
8
+
1
9
* Use ` oven-sh/setup-bun ` in GitHub CI when generating an app with bun
2
10
3
11
* TangRufus*
Original file line number Diff line number Diff line change @@ -412,8 +412,8 @@ def routes_reloader # :nodoc:
412
412
def watchable_args # :nodoc:
413
413
files , dirs = config . watchable_files . dup , config . watchable_dirs . dup
414
414
415
- ActiveSupport :: Dependencies . autoload_paths . each do |path |
416
- File . file? ( path ) ? files << path . to_s : dirs [ path . to_s ] = [ :rb ]
415
+ Rails . autoloaders . main . dirs . each do |path |
416
+ dirs [ path . to_s ] = [ :rb ]
417
417
end
418
418
419
419
[ files , dirs ]
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ def app
13
13
@app ||= Rails . application
14
14
end
15
15
16
- test "watchable_args classifies files included in autoload path" do
16
+ test "watchable_args does NOT include files in autoload path" do
17
17
add_to_config <<-RUBY
18
18
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
19
19
RUBY
@@ -22,7 +22,23 @@ def app
22
22
require "#{ rails_root } /config/environment"
23
23
24
24
files , _ = Rails . application . watchable_args
25
- assert_includes files , "#{ rails_root } /app/README.md"
25
+ assert_not_includes files , "#{ rails_root } /app/README.md"
26
+ end
27
+
28
+ test "watchable_args does include dirs in autoload path" do
29
+ add_to_config <<-RUBY
30
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
31
+ config.autoload_paths += %W(#{ rails_root } /manually-specified-path)
32
+ RUBY
33
+ app_dir "app/automatically-specified-path"
34
+ app_dir "manually-specified-path"
35
+
36
+ require "#{ rails_root } /config/environment"
37
+
38
+ _ , dirs = Rails . application . watchable_args
39
+
40
+ assert_includes dirs , "#{ rails_root } /app/automatically-specified-path"
41
+ assert_includes dirs , "#{ rails_root } /manually-specified-path"
26
42
end
27
43
end
28
44
end
You can’t perform that action at this time.
0 commit comments