diff options
author | James Lopez <james@jameslopez.es> | 2016-02-12 18:01:47 +0100 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-02-12 18:01:47 +0100 |
commit | 4089be8fedbe0499108b32dc0c08b6378efc534c (patch) | |
tree | e05f63c3b942cd488eeec38f4d5c0ba3a6e7fae7 /app/services/system_note_service.rb | |
parent | a5b011c9d8586453d37852856822dab692f6613b (diff) | |
download | gitlab-ce-4089be8fedbe0499108b32dc0c08b6378efc534c.tar.gz |
woo hoo - getting there with the cross-reference issue. Should fix the problem and updated spec
Diffstat (limited to 'app/services/system_note_service.rb')
-rw-r--r-- | app/services/system_note_service.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb index 34b6636c39f..843b44abd17 100644 --- a/app/services/system_note_service.rb +++ b/app/services/system_note_service.rb @@ -280,6 +280,7 @@ class SystemNoteService # mentioner - Mentionable object # # Returns Boolean + def self.cross_reference_exists?(noteable, mentioner) # Initial scope should be system notes of this noteable type notes = Note.system.where(noteable_type: noteable.class) @@ -291,14 +292,20 @@ class SystemNoteService notes = notes.where(noteable_id: noteable.id) end - gfm_reference = mentioner.gfm_reference(nil) - notes = notes.where('note LIKE ?', "#{cross_reference_note_prefix}%#{gfm_reference}") - - notes.count > 0 + notes_for_mentioner(mentioner, noteable, notes).count > 0 end private + def self.notes_for_mentioner(mentioner, noteable, notes) + if mentioner.is_a?(Commit) + notes.where('note LIKE ?', "#{cross_reference_note_prefix}%#{mentioner.to_reference(nil)}") + else + gfm_reference = mentioner.gfm_reference(noteable.project) + notes.where(note: cross_reference_note_content(gfm_reference)) + end + end + def self.create_note(args = {}) Note.create(args.merge(system: true)) end |