Commit 5b6c1a21 authored by Robert Speicher's avatar Robert Speicher

Fix Issue and ExternalIssue reference specs

parent b3b8fc6c
module Gitlab
module Markdown
# HTML filter that replaces external issue tracker references with links.
# References are ignored if the project doesn't use an external issue
# tracker.
class ExternalIssueReferenceFilter < ReferenceFilter
# Public: Find `JIRA-123` issue references in text
#
......@@ -23,6 +25,8 @@ module Gitlab
ISSUE_PATTERN = /(?<issue>([A-Z\-]+-)\d+)/
def call
return doc if project.default_issues_tracker?
replace_text_nodes_matching(ISSUE_PATTERN) do |content|
issue_link_filter(content)
end
......
......@@ -16,13 +16,6 @@ module Gitlab::Markdown
to raise_error(ArgumentError, /:project/)
end
it 'ignores valid references when using non-default tracker' do
expect(project).to receive(:default_issues_tracker?).and_return(false)
exp = act = "Issue ##{issue.iid}"
expect(filter(act).to_html).to eq exp
end
%w(pre code a style).each do |elem|
it "ignores valid references contained inside '#{elem}' element" do
exp = act = "<#{elem}>Issue ##{issue.iid}</#{elem}>"
......@@ -33,6 +26,13 @@ module Gitlab::Markdown
context 'internal reference' do
let(:reference) { "##{issue.iid}" }
it 'ignores valid references when using non-default tracker' do
expect(project).to receive(:issue_exists?).with(issue.iid).and_return(false)
exp = act = "Issue ##{issue.iid}"
expect(filter(act).to_html).to eq exp
end
it 'links to a valid reference' do
doc = filter("See #{reference}")
......@@ -87,6 +87,14 @@ module Gitlab::Markdown
to receive(:user_can_reference_project?).and_return(true)
end
it 'ignores valid references when cross-reference project uses external tracker' do
expect_any_instance_of(Project).to receive(:issue_exists?).
with(issue.iid).and_return(false)
exp = act = "Issue ##{issue.iid}"
expect(filter(act).to_html).to eq exp
end
it 'links to a valid reference' do
doc = filter("See #{reference}")
......
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