aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2019-05-22 16:42:34 -0700
committerJohn Hawthorn <john@hawthorn.email>2019-05-23 12:27:13 -0700
commit2fd6c3799dd04dcae0948acd25c40dded1459756 (patch)
tree07cc823b5dcf971e424e2d5d262e1d91ce1d3ed4 /activesupport/test
parentf1084f2d0eaf8405284b2da19e8ac2c2eb7063ad (diff)
downloadrails-2fd6c3799dd04dcae0948acd25c40dded1459756.tar.gz
rails-2fd6c3799dd04dcae0948acd25c40dded1459756.tar.bz2
rails-2fd6c3799dd04dcae0948acd25c40dded1459756.zip
Fix EventedFileUpdateChecker through a symlink
On MacOS, Dir.tmpdir gives me a folder inside "/var/folders/". However, /var is a symlink to /private/var. Previously, the nonexistent directory test would fail because it was initialized with /var/folders/... but the filenames from listen would be the realpaths. This commit normalizes the dirs by calling realpath on them if they exist. This is done on boot!, so it will work with newly directories through the symlink.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/evented_file_update_checker_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/activesupport/test/evented_file_update_checker_test.rb b/activesupport/test/evented_file_update_checker_test.rb
index ce09fa1586..bec2643b45 100644
--- a/activesupport/test/evented_file_update_checker_test.rb
+++ b/activesupport/test/evented_file_update_checker_test.rb
@@ -77,6 +77,24 @@ 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
watched_dir = File.join(tmpdir, "app")
unwatched_dir = File.join(tmpdir, "node_modules")