1
0
Fork 0
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:
y-yagi 2019-09-03 07:57:41 +09:00 committed by GitHub
commit ef4bf83a1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View file

@ -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]

View 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