Commit 5689a128 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Use absolute URL for scoped label doc link

We need an absolute URL here because relative links in Markdown are
turned into repository file links by RepositoryLinkFilter.
parent 70fce78e
......@@ -74,7 +74,7 @@ module EE
private
def scoped_labels_doc_link
help_url = ::Gitlab::Routing.url_helpers.help_page_path('user/project/labels.md', anchor: 'scoped-labels-premium')
help_url = ::Gitlab::Routing.url_helpers.help_page_url('user/project/labels.md', anchor: 'scoped-labels-premium')
%(<a href="#{help_url}" class="gl-link gl-label-icon" target="_blank" rel="noopener"><i class="fa fa-question-circle"></i></a>).html_safe
end
......
---
title: Fix invalid scoped label documentation URL when rendered in Markdown
merge_request: 28268
author:
type: fixed
......@@ -14,16 +14,18 @@ describe Banzai::Filter::LabelReferenceFilter do
stub_licensed_features(scoped_labels: true)
end
it 'includes link to scoped documentation' do
it 'renders scoped label with link to documentation' do
doc = reference_filter("See #{scoped_label.to_reference}")
expect(doc.to_html).to match(%r(<span.+><a.+><span.+>#{scoped_label.scoped_label_key}</span><span.+>#{scoped_label.scoped_label_value}</span></a><a.+>.*question-circle.*</a></span>))
expect(doc.css('.gl-label-scoped .gl-label-text').map(&:text)).to eq([scoped_label.scoped_label_key, scoped_label.scoped_label_value])
expect(doc.at_css('a.gl-label-icon')['href']).to eq('http://localhost/help/user/project/labels.md#scoped-labels-premium')
end
it 'does not include link to scoped documentation for common labels' do
it 'renders common label' do
doc = reference_filter("See #{label.to_reference}")
expect(doc.to_html).to match(%r(<span.+><a.+><span.+>#{label.name}</span></a></span>$))
expect(doc.css('.gl-label .gl-label-text').map(&:text)).to eq([label.name])
expect(doc.at_css('a.gl-label-icon')).to be_nil
end
end
......@@ -32,10 +34,11 @@ describe Banzai::Filter::LabelReferenceFilter do
stub_licensed_features(scoped_labels: false)
end
it 'renders label as a common label' do
it 'renders scoped label as a common label' do
doc = reference_filter("See #{scoped_label.to_reference}")
expect(doc.to_html).to match(%r(<span.+><a.+><span.+>#{scoped_label.name}</span></a></span>$))
expect(doc.css('.gl-label .gl-label-text').map(&:text)).to eq([scoped_label.name])
expect(doc.at_css('a.gl-label-icon')).to be_nil
end
end
end
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