Commit ff3a62aa authored by Robert Speicher's avatar Robert Speicher

Remove legacy special case for emphasized reference notes

parent cdb69d72
......@@ -196,7 +196,7 @@ class SystemNoteService
end
gfm_reference = mentioner_gfm_ref(noteable, mentioner, true)
notes = notes.where('note like ?', cross_reference_note_pattern(gfm_reference))
notes = notes.where(note: cross_reference_note_content(gfm_reference))
notes.count > 0
end
......@@ -207,17 +207,14 @@ class SystemNoteService
Note.create(args.merge(system: true))
end
def self.cross_reference_note_prefix
'mentioned in '
end
# Prepend the mentioner's namespaced project path to the GFM reference for
# cross-project references. For same-project references, return the
# unmodified GFM reference.
def self.mentioner_gfm_ref(noteable, mentioner, cross_reference = false)
if mentioner.is_a?(Commit) && cross_reference
return mentioner.gfm_reference.sub('commit ', 'commit %')
end
# FIXME (rspeicher): This was breaking things.
# if mentioner.is_a?(Commit) && cross_reference
# return mentioner.gfm_reference.sub('commit ', 'commit %')
# end
full_gfm_reference(mentioner.project, noteable.project, mentioner)
end
......@@ -243,13 +240,12 @@ class SystemNoteService
end
end
def self.cross_reference_note_content(gfm_reference)
cross_reference_note_prefix + "#{gfm_reference}"
def self.cross_reference_note_prefix
'mentioned in '
end
def self.cross_reference_note_pattern(gfm_reference)
# Older cross reference notes contained underscores for emphasis
"%" + cross_reference_note_content(gfm_reference) + "%"
def self.cross_reference_note_content(gfm_reference)
"#{cross_reference_note_prefix}#{gfm_reference}"
end
# Build an Array of lines detailing each commit added in a merge request
......
......@@ -313,41 +313,5 @@ describe SystemNoteService do
to be_falsey
end
end
context 'legacy note with Markdown emphasis' do
let(:mentioner) { create(:issue, project: project) }
before do
note = "_mentioned in issue ##{mentioner.iid}_"
create(:system_note, noteable: noteable, note: note, project: project)
end
it 'detects if a mentionable with emphasis has been mentioned' do
expect(described_class.cross_reference_exists?(noteable, mentioner)).
to be_truthy
end
context 'when referenced project has underscores' do
let(:project) { create(:empty_project, path: 'first_project') }
let(:project2) { create(:empty_project, path: 'second_project') }
let(:issue) { mentioner }
let(:issue2) { create(:issue, project: project2) }
before do
described_class.cross_reference(issue, issue2, author)
end
it 'is truthy when already mentioned' do
expect(described_class.cross_reference_exists?(issue, issue2)).
to be_truthy
end
it 'is falsey when not already mentioned' do
expect(described_class.cross_reference_exists?(issue2, issue)).
to be_falsey
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment