summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejandroluis24@gmail.com>2016-03-31 21:54:00 -0300
committerAlejandro Rodríguez <alejandroluis24@gmail.com>2016-04-20 22:12:43 -0300
commit375e83bb57dc0143691cf6ef7277bec494f060f0 (patch)
tree24163c348d59ed596aa47328fac7d24ce6a4728c /lib
parent077f9a4eeef3c64c5f3e9cc5df5442c8817ee1d6 (diff)
downloadgitlab-ce-375e83bb57dc0143691cf6ef7277bec494f060f0.tar.gz
Consistently using iid when treating milestones as referrables
Also, addint a suffix to the reference text when the milestone is in another project
Diffstat (limited to 'lib')
-rw-r--r--lib/banzai/filter/milestone_reference_filter.rb19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/banzai/filter/milestone_reference_filter.rb b/lib/banzai/filter/milestone_reference_filter.rb
index 2c90fd4d385..419532717f2 100644
--- a/lib/banzai/filter/milestone_reference_filter.rb
+++ b/lib/banzai/filter/milestone_reference_filter.rb
@@ -7,17 +7,17 @@ module Banzai
end
def find_object(project, id)
- project.milestones.find(id)
+ project.milestones.find_by(iid: id)
end
def references_in(text, pattern = Milestone.reference_pattern)
text.gsub(pattern) do |match|
project = project_from_ref($~[:project])
- params = milestone_params($~[:milestone_id].to_i, $~[:milestone_name])
+ params = milestone_params($~[:milestone_iid].to_i, $~[:milestone_name])
milestone = project.milestones.find_by(params)
if milestone
- yield match, milestone.id, $~[:project], $~
+ yield match, milestone.iid, $~[:project], $~
else
match
end
@@ -30,11 +30,20 @@ module Banzai
only_path: context[:only_path])
end
- def milestone_params(id, name)
+ def object_link_text(object, matches)
+ if context[:project] == object.project
+ super
+ else
+ "#{super} <i>in #{escape_once(object.project.name_with_namespace)}</i>".
+ html_safe
+ end
+ end
+
+ def milestone_params(iid, name)
if name
{ name: name.tr('"', '') }
else
- { id: id }
+ { iid: iid }
end
end
end