diff options
author | Alejandro RodrÃguez <alejandroluis24@gmail.com> | 2016-04-05 04:20:10 +0300 |
---|---|---|
committer | Alejandro RodrÃguez <alejandroluis24@gmail.com> | 2016-04-21 04:12:43 +0300 |
commit | 6d9794d42a7bea1150374c76fd3ce5521a44e58e (patch) | |
tree | 3be96947c2cf334f14c517f0543ac8298b0c4078 | |
parent | 375e83bb57dc0143691cf6ef7277bec494f060f0 (diff) |
Transforming milestones link references to the short reference form
-rw-r--r-- | lib/banzai/filter/milestone_reference_filter.rb | 5 | ||||
-rw-r--r-- | spec/fixtures/markdown.md.erb | 1 | ||||
-rw-r--r-- | spec/support/matchers/markdown_matchers.rb | 2 |
3 files changed, 7 insertions, 1 deletions
diff --git a/lib/banzai/filter/milestone_reference_filter.rb b/lib/banzai/filter/milestone_reference_filter.rb index 419532717f2..556087c4880 100644 --- a/lib/banzai/filter/milestone_reference_filter.rb +++ b/lib/banzai/filter/milestone_reference_filter.rb @@ -11,6 +11,11 @@ module Banzai end def references_in(text, pattern = Milestone.reference_pattern) + # We'll handle here the references that follow the `reference_pattern`. + # Other patterns (for example, the link pattern) are handled by the + # default implementation. + return super(text, pattern) if pattern != Milestone.reference_pattern + text.gsub(pattern) do |match| project = project_from_ref($~[:project]) params = milestone_params($~[:milestone_iid].to_i, $~[:milestone_name]) diff --git a/spec/fixtures/markdown.md.erb b/spec/fixtures/markdown.md.erb index 6d3bf810c2c..3e777a5e92b 100644 --- a/spec/fixtures/markdown.md.erb +++ b/spec/fixtures/markdown.md.erb @@ -222,6 +222,7 @@ References should be parseable even inside _<%= merge_request.to_reference %>_ e - Milestone in another project: <%= xmilestone.to_reference(project) %> - Ignored in code: `<%= simple_milestone.to_reference %>` - Ignored in links: [Link to <%= simple_milestone.to_reference %>](#milestone-link) +- Milestone by URL: <%= urls.namespace_project_milestone_url(milestone.project.namespace, milestone.project, milestone) %> - Link to milestone by URL: [Milestone](<%= milestone.to_reference %>) ### Task Lists diff --git a/spec/support/matchers/markdown_matchers.rb b/spec/support/matchers/markdown_matchers.rb index 492138716af..d921f9bb2bc 100644 --- a/spec/support/matchers/markdown_matchers.rb +++ b/spec/support/matchers/markdown_matchers.rb @@ -154,7 +154,7 @@ module MarkdownMatchers set_default_markdown_messages match do |actual| - expect(actual).to have_selector('a.gfm.gfm-milestone', count: 5) + expect(actual).to have_selector('a.gfm.gfm-milestone', count: 6) end end |