handle non strings passed to Page.cname

This commit is contained in:
rick
2010-09-13 15:48:54 -07:00
parent e774ceaf1f
commit 430436ce8d
2 changed files with 8 additions and 1 deletions
+3 -1
View File
@@ -202,7 +202,9 @@ module Gollum
#
# Returns the String canonical name.
def self.cname(name)
name.gsub(%r{[ /<>]}, '-')
name.respond_to?(:gsub) ?
name.gsub(%r{[ /<>]}, '-') :
''
end
# Convert a format Symbol into an extension String.
+5
View File
@@ -110,4 +110,9 @@ context "Page" do
footer = @wiki.page("_Footer")
assert_nil footer.footer
end
test "cannot convert non string to human readable page title" do
assert_equal '', Gollum::Page.cname(nil)
assert_equal '', Gollum::Page.cname(3)
end
end