Hide number sign for string prefixed external issues
This commit is contained in:
parent
b372968e93
commit
3918fce5bd
|
@ -34,15 +34,13 @@ class ExternalIssue
|
|||
%r{(?<issue>\b([A-Z][A-Z0-9_]+-)\d+)}
|
||||
end
|
||||
|
||||
def self.reference_prefix
|
||||
'#'
|
||||
end
|
||||
|
||||
def to_reference(_from_project = nil)
|
||||
id
|
||||
end
|
||||
|
||||
def reference_link_text(from_project = nil)
|
||||
"#{self.class.reference_prefix}#{id}"
|
||||
return "##{id}" if /^\d+$/.match(id)
|
||||
|
||||
id
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,8 +38,17 @@ describe ExternalIssue, models: true do
|
|||
end
|
||||
|
||||
describe '#reference_link_text' do
|
||||
it 'returns a String reference to the object' do
|
||||
expect(issue.reference_link_text).to eq '#EXT-1234'
|
||||
context 'if issue id has a prefix' do
|
||||
it 'returns the issue ID' do
|
||||
expect(issue.reference_link_text).to eq 'EXT-1234'
|
||||
end
|
||||
end
|
||||
|
||||
context 'if issue id is a number' do
|
||||
let(:issue) { described_class.new('1234', project) }
|
||||
it 'returns the issue ID prefixed by #' do
|
||||
expect(issue.reference_link_text).to eq '#1234'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue