summaryrefslogtreecommitdiff
path: root/app/models/group_label.rb
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-10-11 16:51:11 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-10-19 14:58:26 -0200
commit0e8dd599134f17e58cf533ab21cf3c4a5b50c353 (patch)
tree3d55561fe27868758ee974ab005b2e69d32916bc /app/models/group_label.rb
parent247859c82915a0ee88944c1fcda3f6faf49e54c0 (diff)
downloadgitlab-ce-0e8dd599134f17e58cf533ab21cf3c4a5b50c353.tar.gz
Move common logic to reference group/project label to Label#to_reference
Diffstat (limited to 'app/models/group_label.rb')
-rw-r--r--app/models/group_label.rb27
1 files changed, 1 insertions, 26 deletions
diff --git a/app/models/group_label.rb b/app/models/group_label.rb
index c7efa29a5f6..a1d8d087726 100644
--- a/app/models/group_label.rb
+++ b/app/models/group_label.rb
@@ -3,32 +3,7 @@ class GroupLabel < Label
validates :group, presence: true
- ##
- # Returns the String necessary to reference this GroupLabel in Markdown
- #
- # format - Symbol format to use (default: :id, optional: :name)
- #
- # Examples:
- #
- # GroupLabel.first.to_reference # => "~1"
- # GroupLabel.first.to_reference(format: :name) # => "~\"bug\""
- #
- # Returns a String
- #
def to_reference(source_project = nil, target_project = nil, format: :id)
- format_reference = label_format_reference(format)
- reference = "#{self.class.reference_prefix}#{format_reference}"
-
- if cross_project_reference?(source_project, target_project)
- source_project.to_reference + reference
- else
- reference
- end
- end
-
- private
-
- def cross_project_reference?(source_project, target_project)
- source_project && target_project && source_project != target_project
+ super(source_project, target_project, format: format)
end
end