From eda503c836c6cd02937e111b175979c5722677fd Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 10 Nov 2015 02:28:14 -0800 Subject: the evented monitor filters out descendants --- .../test/file_evented_update_checker_test.rb | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'activesupport/test') 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 -- cgit v1.2.3