test/paths_test.rb in asciidoctor-1.5.7.1 vs test/paths_test.rb in asciidoctor-1.5.8

- old
+ new

@@ -274,14 +274,31 @@ test 'resolves absolute path if start is absolute and target is relative' do assert_equal '/usr/share/assets/stylesheet.css', @resolver.system_path('assets/stylesheet.css', '/usr/share') end - test 'resolves absolute UNC path if start is absolute and target is relative' do + test 'File.dirname preserves UNC path root on Windows' do + assert_equal File.dirname('\\\\server\\docs\\file.html'), '\\\\server\\docs' + end if windows? + + test 'File.dirname preserves posix-style UNC path root on Windows' do + assert_equal File.dirname('//server/docs/file.html'), '//server/docs' + end if windows? + + test 'resolves UNC path if start is absolute and target is relative' do assert_equal '//QA/c$/users/asciidoctor/assets/stylesheet.css', @resolver.system_path('assets/stylesheet.css', '//QA/c$/users/asciidoctor') end + test 'resolves UNC path if target is UNC path' do + @resolver.file_separator = '\\' + assert_equal '//server/docs/output.html', @resolver.system_path('\\\\server\\docs\\output.html') + end + + test 'resolves UNC path if target is posix-style UNC path' do + assert_equal '//server/docs/output.html', @resolver.system_path('//server/docs/output.html') + end + test 'resolves relative target relative to current directory if start is empty' do pwd = File.expand_path(Dir.pwd) assert_equal "#{pwd}/images/tiger.png", @resolver.system_path('images/tiger.png', '') assert_equal "#{pwd}/images/tiger.png", @resolver.system_path('images/tiger.png', nil) assert_equal "#{pwd}/images/tiger.png", @resolver.system_path('images/tiger.png') @@ -328,14 +345,14 @@ filename = @resolver.system_path('part1/chapter1/section1.adoc', nil, JAIL) assert_equal "#{JAIL}/part1/chapter1/section1.adoc", filename assert_equal 'part1/chapter1/section1.adoc', @resolver.relative_path(filename, JAIL) end - test 'should resolve relative path to filename if does not share common root with base directory' do - filename = '/docs/partials' + test 'should resolve relative path to filename outside of base directory' do + filename = '/home/shared/partials' base_dir = '/home/user/docs' result = @resolver.relative_path filename, base_dir - assert_equal filename, result + assert_equal '../../shared/partials', result end test 'should resolve relative path relative to base dir in unsafe mode' do base_dir = fixture_path 'base' doc = empty_document :base_dir => base_dir, :safe => Asciidoctor::SafeMode::UNSAFE