Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly classify the files and directories that pass to watcher #37102

Merged
merged 1 commit into from Sep 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion railties/lib/rails/application.rb
Expand Up @@ -351,7 +351,7 @@ def watchable_args #:nodoc:
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]
Expand Down
28 changes: 28 additions & 0 deletions railties/test/application/watcher_test.rb
@@ -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