Commit d520fe07 authored by Robert Speicher's avatar Robert Speicher

Fix GitlabMarkdownHelper spec

parent 96c2b940
...@@ -51,8 +51,8 @@ describe GitlabMarkdownHelper do ...@@ -51,8 +51,8 @@ describe GitlabMarkdownHelper do
end end
it "should not touch HTML entities" do it "should not touch HTML entities" do
allow(@project.issues).to receive(:where). allow(@project).to receive(:issue_exists?).
with(id: '39').and_return([issue]) with(39).and_return([issue])
actual = 'We'll accept good pull requests.' actual = 'We'll accept good pull requests.'
expect(gfm(actual)).to eq("We'll accept good pull requests.") expect(gfm(actual)).to eq("We'll accept good pull requests.")
end end
...@@ -609,7 +609,7 @@ describe GitlabMarkdownHelper do ...@@ -609,7 +609,7 @@ describe GitlabMarkdownHelper do
end end
it "should leave ref-like href of 'manual' links untouched" do it "should leave ref-like href of 'manual' links untouched" do
expect(markdown("why not [inspect !#{merge_request.iid}](http://example.tld/#!#{merge_request.iid})")).to eq("<p>why not <a href=\"http://example.tld/#!#{merge_request.iid}\">inspect </a><a href=\"#{namespace_project_merge_request_path(project.namespace, project, merge_request)}\" title=\"Merge Request: #{merge_request.title}\" class=\"gfm gfm-merge_request \">!#{merge_request.iid}</a><a href=\"http://example.tld/#!#{merge_request.iid}\"></a></p>\n") expect(markdown("why not [inspect !#{merge_request.iid}](http://example.tld/#!#{merge_request.iid})")).to eq("<p>why not <a href=\"http://example.tld/#!#{merge_request.iid}\">inspect </a><a href=\"#{namespace_project_merge_request_path(project.namespace, project, merge_request)}\" title=\"Merge Request: #{merge_request.title}\" class=\"gfm gfm-merge_request\">!#{merge_request.iid}</a><a href=\"http://example.tld/#!#{merge_request.iid}\"></a></p>\n")
end end
it "should leave ref-like src of images untouched" do it "should leave ref-like src of images untouched" do
......
...@@ -38,6 +38,14 @@ module Gitlab::Markdown ...@@ -38,6 +38,14 @@ module Gitlab::Markdown
to eq urls.namespace_project_compare_url(project.namespace, project, from: commit1.id, to: commit2.id) to eq urls.namespace_project_compare_url(project.namespace, project, from: commit1.id, to: commit2.id)
end end
it 'links to a valid short ID' do
reference = "#{commit1.short_id}...#{commit2.id}"
reference2 = "#{commit1.id}...#{commit2.short_id}"
expect(filter("See #{reference}").css('a').first.text).to eq reference
expect(filter("See #{reference2}").css('a').first.text).to eq reference2
end
it 'links with adjacent text' do it 'links with adjacent text' do
doc = filter("See (#{reference}.)") doc = filter("See (#{reference}.)")
expect(doc.to_html).to match(/\(<a.+>#{Regexp.escape(reference)}<\/a>\.\)/) expect(doc.to_html).to match(/\(<a.+>#{Regexp.escape(reference)}<\/a>\.\)/)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment