Remove redundant code in cross project labels implementation

This commit is contained in:
Grzegorz Bizon 2016-03-03 10:39:18 +01:00
parent 34769efa79
commit fa639df5c7
2 changed files with 4 additions and 7 deletions

View File

@ -85,7 +85,8 @@ class Label < ActiveRecord::Base
# Returns a String
#
def to_reference(from_project = nil, format: :id)
reference = label_format_reference(format)
format_reference = label_format_reference(format)
reference = "#{self.class.reference_prefix}#{format_reference}"
if cross_project_reference?(from_project)
project.to_reference + reference
@ -116,9 +117,9 @@ class Label < ActiveRecord::Base
raise StandardError, 'Unknown format' unless [:id, :name].include?(format)
if format == :name && !name.include?('"')
%(#{self.class.reference_prefix}"#{name}")
%("#{name}")
else
"#{self.class.reference_prefix}#{id}"
id
end
end
end

View File

@ -16,10 +16,6 @@ module Banzai
end
end
def self.referenced_by(node)
{ label: LazyReference.new(Label, node.attr("data-label")) }
end
def references_in(text, pattern = Label.reference_pattern)
text.gsub(pattern) do |match|
project = project_from_ref($~[:project])