fix tests for normalize_dir

This commit is contained in:
rick
2010-12-31 12:30:23 -06:00
parent 6ffff4e586
commit 4fa3951718
2 changed files with 6 additions and 4 deletions
+2 -1
View File
@@ -67,9 +67,10 @@ module Gollum
# Returns a normalized String directory name, or nil if no directory # Returns a normalized String directory name, or nil if no directory
# is given. # is given.
def self.normalize_dir(dir) def self.normalize_dir(dir)
return '' if dir =~ /^.:\/$/
if dir if dir
dir = ::File.expand_path(dir, '/') dir = ::File.expand_path(dir, '/')
dir = '' if (dir == '/' || dir =~ /^.:\/$/) dir = '' if dir == '/'
end end
dir dir
end end
+1
View File
@@ -139,6 +139,7 @@ context "Page" do
assert_equal "", Gollum::BlobEntry.normalize_dir("") assert_equal "", Gollum::BlobEntry.normalize_dir("")
assert_equal "", Gollum::BlobEntry.normalize_dir(".") assert_equal "", Gollum::BlobEntry.normalize_dir(".")
assert_equal "", Gollum::BlobEntry.normalize_dir("/") assert_equal "", Gollum::BlobEntry.normalize_dir("/")
assert_equal "", Gollum::BlobEntry.normalize_dir("c:/")
assert_equal "/foo", Gollum::BlobEntry.normalize_dir("foo") assert_equal "/foo", Gollum::BlobEntry.normalize_dir("foo")
assert_equal "/foo", Gollum::BlobEntry.normalize_dir("/foo") assert_equal "/foo", Gollum::BlobEntry.normalize_dir("/foo")
end end