summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-02-18 09:40:42 +0100
committerDouwe Maan <douwe@gitlab.com>2015-02-18 12:32:20 +0100
commit15bee7e0ffa2f7eccd700da0238ad7a7e66ddbb0 (patch)
tree60f97f68a86ba7ef302501852bff391c3a440dad /spec
parent0da0d800f2a0db9d9c16cf5e2feb0dd80b528223 (diff)
downloadgitlab-ce-15bee7e0ffa2f7eccd700da0238ad7a7e66ddbb0.tar.gz
Fix Markdown relative links to files with anchors.
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/gitlab_markdown_helper_spec.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb
index 317a559f83c..ab908a3d61e 100644
--- a/spec/helpers/gitlab_markdown_helper_spec.rb
+++ b/spec/helpers/gitlab_markdown_helper_spec.rb
@@ -584,7 +584,7 @@ describe GitlabMarkdownHelper do
it "should leave code blocks untouched" do
allow(helper).to receive(:user_color_scheme_class).and_return(:white)
- target_html = "<pre class=\"code highlight white plaintext\"><code>some code from $40\nhere too\n</code></pre>\n"
+ target_html = "<pre class=\"code highlight white plaintext\"><code>some code from $#{snippet.id}\nhere too\n</code></pre>\n"
expect(helper.markdown("\n some code from $#{snippet.id}\n here too\n")).
to eq(target_html)
@@ -638,6 +638,18 @@ describe GitlabMarkdownHelper do
expect(markdown(actual)).to match(expected)
end
+ it "should handle relative urls for a file in master with an anchor" do
+ actual = "[GitLab API doc](doc/api/README.md#section)\n"
+ expected = "<p><a href=\"/#{project.path_with_namespace}/blob/#{@ref}/doc/api/README.md#section\">GitLab API doc</a></p>\n"
+ expect(markdown(actual)).to match(expected)
+ end
+
+ it "should not handle relative urls for the current file with an anchor" do
+ actual = "[GitLab API doc](#section)\n"
+ expected = "<p><a href=\"#section\">GitLab API doc</a></p>\n"
+ expect(markdown(actual)).to match(expected)
+ end
+
it "should handle relative urls for a directory in master" do
actual = "[GitLab API doc](doc/api)\n"
expected = "<p><a href=\"/#{project.path_with_namespace}/tree/#{@ref}/doc/api\">GitLab API doc</a></p>\n"