Add test for #542

This commit is contained in:
bootstraponline
2012-10-13 12:57:58 -06:00
parent 66fc8a2d31
commit 432f9b8d2f
2 changed files with 22 additions and 0 deletions
+6
View File
@@ -407,6 +407,12 @@ module Gollum
presence = "present"
end
link = ::File.join(@wiki.base_path, page ? page.escaped_url_path : CGI.escape(link_name))
# //page is invalid
# strip all duplicate forward slashes using helpers.rb clean_url
# //page => /page
# link = one_leading_slash link
%{<a class="internal #{presence}" href="#{link}#{extra}">#{name}</a>}
end
end
+16
View File
@@ -55,6 +55,22 @@ context "Markup" do
#
#########################################################################
test "absolute link to non-existant page" do
@wiki.write_page("linktest", :markdown, "[[/page]]", commit_details)
# "<p>a <a class=\"internal absent\" href=\"/Foo\">Foo</a><a class=\"internal absent\" href=\"/Bar\">Bar</a> b</p>"
page = @wiki.page("linktest")
doc = Nokogiri::HTML page.formatted_data
paras = doc / :p
para = paras.first
anchors = para / :a
assert_equal 1, paras.size
assert_equal 1, anchors.size
assert_equal 'internal absent', anchors[0]['class']
assert_equal '/Page', anchors[0]['href']
assert_equal 'Page', anchors[0].text
end
test "double page links no space" do
@wiki.write_page("Bilbo Baggins", :markdown, "a [[Foo]][[Bar]] b", commit_details)