Milestone reference is a Markdown link
This commit is contained in:
parent
b38eabdaf6
commit
539b41929b
3 changed files with 8 additions and 3 deletions
|
@ -71,8 +71,12 @@ class Milestone < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def to_reference(from_project = nil)
|
||||
escaped_title = self.title.gsub("]", "\\]")
|
||||
|
||||
h = Gitlab::Application.routes.url_helpers
|
||||
h.namespace_project_milestone_url(self.project.namespace, self.project, self)
|
||||
url = h.namespace_project_milestone_url(self.project.namespace, self.project, self)
|
||||
|
||||
"[#{escaped_title}](#{url})"
|
||||
end
|
||||
|
||||
def reference_link_text(from_project = nil)
|
||||
|
|
1
spec/fixtures/markdown.md.erb
vendored
1
spec/fixtures/markdown.md.erb
vendored
|
@ -219,7 +219,6 @@ References should be parseable even inside _<%= merge_request.to_reference %>_ e
|
|||
- Milestone: <%= milestone.to_reference %>
|
||||
- Milestone in another project: <%= xmilestone.to_reference(project) %>
|
||||
- Ignored in code: `<%= milestone.to_reference %>`
|
||||
- Ignored in links: [Link to <%= milestone.to_reference %>](#milestone-link)
|
||||
- Link to milestone by URL: [Milestone](<%= urls.namespace_project_milestone_url(milestone.project.namespace, milestone.project, milestone) %>)
|
||||
|
||||
### Task Lists
|
||||
|
|
|
@ -18,7 +18,9 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do
|
|||
end
|
||||
|
||||
context 'internal reference' do
|
||||
let(:reference) { milestone.to_reference }
|
||||
# Convert the Markdown link to only the URL, since these tests aren't run through the regular Markdown pipeline.
|
||||
# Milestone reference behavior in the full Markdown pipeline is tested elsewhere.
|
||||
let(:reference) { milestone.to_reference.gsub(/\[([^\]]+)\]\(([^)]+)\)/, '\2') }
|
||||
|
||||
it 'links to a valid reference' do
|
||||
doc = reference_filter("See #{reference}")
|
||||
|
|
Loading…
Reference in a new issue