mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #37102 from y-yagi/fixes_37011
Correctly classify the files and directories that pass to watcher
This commit is contained in:
commit
ef4bf83a1b
2 changed files with 29 additions and 1 deletions
|
@ -351,7 +351,7 @@ module Rails
|
|||
files, dirs = config.watchable_files.dup, config.watchable_dirs.dup
|
||||
|
||||
ActiveSupport::Dependencies.autoload_paths.each do |path|
|
||||
dirs[path.to_s] = [:rb]
|
||||
File.file?(path) ? files << path.to_s : dirs[path.to_s] = [:rb]
|
||||
end
|
||||
|
||||
[files, dirs]
|
||||
|
|
28
railties/test/application/watcher_test.rb
Normal file
28
railties/test/application/watcher_test.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "isolation/abstract_unit"
|
||||
|
||||
module ApplicationTests
|
||||
class WatcherTest < ActiveSupport::TestCase
|
||||
include ActiveSupport::Testing::Isolation
|
||||
|
||||
setup :build_app
|
||||
teardown :teardown_app
|
||||
|
||||
def app
|
||||
@app ||= Rails.application
|
||||
end
|
||||
|
||||
test "watchable_args classifies files included in autoload path" do
|
||||
add_to_config <<-RUBY
|
||||
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
||||
RUBY
|
||||
app_file "app/README.md", ""
|
||||
|
||||
require "#{rails_root}/config/environment"
|
||||
|
||||
files, _ = Rails.application.watchable_args
|
||||
assert_includes files, "#{rails_root}/app/README.md"
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue