diff options
Diffstat (limited to 'activesupport/test/evented_file_update_checker_test.rb')
-rw-r--r-- | activesupport/test/evented_file_update_checker_test.rb | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/activesupport/test/evented_file_update_checker_test.rb b/activesupport/test/evented_file_update_checker_test.rb index b2d5eb94c2..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 @@ -156,14 +172,6 @@ class EventedFileUpdateCheckerPathHelperTest < ActiveSupport::TestCase assert_nil @ph.longest_common_subpath([]) end - test "#existing_parent returns the most specific existing ascendant" do - wd = Pathname.getwd - - assert_equal wd, @ph.existing_parent(wd) - assert_equal wd, @ph.existing_parent(wd.join("non-existing/directory")) - assert_equal pn("/"), @ph.existing_parent(pn("/non-existing/directory")) - end - test "#filter_out_descendants returns the same collection if there are no descendants (empty)" do assert_equal [], @ph.filter_out_descendants([]) end |