aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/evented_file_update_checker_test.rb
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2019-05-24 16:08:43 -0500
committerGitHub <noreply@github.com>2019-05-24 16:08:43 -0500
commit81d1242c77d74f6c0ca9d52971ccae2581528f1e (patch)
treedeb565001295b69220902608fbf33f9460614039 /activesupport/test/evented_file_update_checker_test.rb
parent5c14eb0b4ea3bde067bc8fce7ed99f5f10ab16ff (diff)
parent2fd6c3799dd04dcae0948acd25c40dded1459756 (diff)
downloadrails-81d1242c77d74f6c0ca9d52971ccae2581528f1e.tar.gz
rails-81d1242c77d74f6c0ca9d52971ccae2581528f1e.tar.bz2
rails-81d1242c77d74f6c0ca9d52971ccae2581528f1e.zip
Merge pull request #36340 from jhawthorn/evented_file_checker_symlink
Fix EventedFileUpdateChecker through a symlink
Diffstat (limited to 'activesupport/test/evented_file_update_checker_test.rb')
-rw-r--r--activesupport/test/evented_file_update_checker_test.rb56
1 files changed, 36 insertions, 20 deletions
diff --git a/activesupport/test/evented_file_update_checker_test.rb b/activesupport/test/evented_file_update_checker_test.rb
index a6bd2ade31..4d5a9bed7a 100644
--- a/activesupport/test/evented_file_update_checker_test.rb
+++ b/activesupport/test/evented_file_update_checker_test.rb
@@ -77,32 +77,48 @@ class EventedFileUpdateCheckerTest < ActiveSupport::TestCase
Process.wait(pid)
end
+ test "should detect changes through symlink" do
+ actual_dir = File.join(tmpdir, "actual")
+ linked_dir = File.join(tmpdir, "linked")
+
+ Dir.mkdir(actual_dir)
+ FileUtils.ln_s(actual_dir, linked_dir)
+
+ checker = new_checker([], linked_dir => ".rb") { }
+
+ assert_not_predicate checker, :updated?
+
+ FileUtils.touch(File.join(actual_dir, "a.rb"))
+ wait
+
+ assert_predicate checker, :updated?
+ assert checker.execute_if_updated
+ end
+
test "updated should become true when nonexistent directory is added later" do
- Dir.mktmpdir do |dir|
- watched_dir = File.join(dir, "app")
- unwatched_dir = File.join(dir, "node_modules")
- not_exist_watched_dir = File.join(dir, "test")
+ watched_dir = File.join(tmpdir, "app")
+ unwatched_dir = File.join(tmpdir, "node_modules")
+ not_exist_watched_dir = File.join(tmpdir, "test")
- Dir.mkdir(watched_dir)
- Dir.mkdir(unwatched_dir)
+ Dir.mkdir(watched_dir)
+ Dir.mkdir(unwatched_dir)
- checker = new_checker([], watched_dir => ".rb", not_exist_watched_dir => ".rb") { }
+ checker = new_checker([], watched_dir => ".rb", not_exist_watched_dir => ".rb") { }
- FileUtils.touch(File.join(watched_dir, "a.rb"))
- wait
- assert_predicate checker, :updated?
- assert checker.execute_if_updated
+ FileUtils.touch(File.join(watched_dir, "a.rb"))
+ wait
+ assert_predicate checker, :updated?
+ assert checker.execute_if_updated
- Dir.mkdir(not_exist_watched_dir)
- wait
- assert_predicate checker, :updated?
- assert checker.execute_if_updated
+ Dir.mkdir(not_exist_watched_dir)
+ wait
+ assert_predicate checker, :updated?
+ assert checker.execute_if_updated
- FileUtils.touch(File.join(unwatched_dir, "a.rb"))
- wait
- assert_not_predicate checker, :updated?
- assert_not checker.execute_if_updated
- end
+ FileUtils.touch(File.join(unwatched_dir, "a.rb"))
+ wait
+ assert_not_predicate checker, :updated?
+ assert_not checker.execute_if_updated
end
end