aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2015-11-10 02:28:14 -0800
committerXavier Noria <fxn@hashref.com>2015-11-10 03:36:25 -0800
commiteda503c836c6cd02937e111b175979c5722677fd (patch)
tree75b2b95ce3f9679186c04e0b06d0c9e38703677d /activesupport/test
parent8a64824306fd04895f4f6f14e6edb7a82bfe2503 (diff)
downloadrails-eda503c836c6cd02937e111b175979c5722677fd.tar.gz
rails-eda503c836c6cd02937e111b175979c5722677fd.tar.bz2
rails-eda503c836c6cd02937e111b175979c5722677fd.zip
the evented monitor filters out descendants
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/file_evented_update_checker_test.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/activesupport/test/file_evented_update_checker_test.rb b/activesupport/test/file_evented_update_checker_test.rb
index 93b62fe5b7..5aba9a3e0b 100644
--- a/activesupport/test/file_evented_update_checker_test.rb
+++ b/activesupport/test/file_evented_update_checker_test.rb
@@ -88,4 +88,34 @@ class FileEventedUpdateCheckerPathHelperTest < ActiveSupport::TestCase
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
+
+ test '#filter_out_descendants returns the same collection if there are no descendants (one)' do
+ assert_equal ['/foo'], @ph.filter_out_descendants(['/foo'])
+ end
+
+ test '#filter_out_descendants returns the same collection if there are no descendants (several)' do
+ paths = %w(
+ /Rails.root/app/controllers
+ /Rails.root/app/models
+ /Rails.root/app/helpers
+ ).map {|path| pn(path)}
+
+ assert_equal paths, @ph.filter_out_descendants(paths)
+ end
+
+ test '#filter_out_descendants filters out descendants preserving order' do
+ paths = %w(
+ /Rails.root/app/controllers
+ /Rails.root/app/controllers/concerns
+ /Rails.root/app/models
+ /Rails.root/app/models/concerns
+ /Rails.root/app/helpers
+ ).map {|path| pn(path)}
+
+ assert_equal paths.values_at(0, 2, 4), @ph.filter_out_descendants(paths)
+ end
end