diff options
author | Stan Hu <stan@gitlab.com> | 2017-10-14 19:40:04 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-10-15 18:00:08 -0700 |
commit | 774374b9285b440c5eead67e49cb10c4a097a98b (patch) | |
tree | c65bf13934fcc227d8d2d50853c9563b82f89ac1 | |
parent | 0190b014508c30cad86e55663010ba63f64c1016 (diff) | |
download | gitlab-ce-774374b9285b440c5eead67e49cb10c4a097a98b.tar.gz |
Merge branch '3435-backport-9-4' into 'security-9-4'
3435 backport for 9.4
See merge request gitlab/gitlabhq!2206
-rw-r--r-- | app/models/note.rb | 2 | ||||
-rw-r--r-- | app/services/system_note_service.rb | 7 | ||||
-rw-r--r-- | spec/controllers/projects/issues_controller_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/system_note_service_spec.rb | 14 |
4 files changed, 2 insertions, 23 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index 3d39047d32f..6a60a13a53c 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -144,7 +144,7 @@ class Note < ActiveRecord::Base end def cross_reference? - system? && SystemNoteService.cross_reference?(note) + system? && matches_cross_reference_regex? end def diff_note? diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb index da0f21d449a..88363fc57f4 100644 --- a/app/services/system_note_service.rb +++ b/app/services/system_note_service.rb @@ -161,7 +161,6 @@ module SystemNoteService # "changed time estimate to 3d 5h" # # Returns the created Note object - def change_time_estimate(noteable, project, author) parsed_time = Gitlab::TimeTrackingFormatter.output(noteable.time_estimate) body = if noteable.time_estimate == 0 @@ -187,7 +186,6 @@ module SystemNoteService # "added 2h 30m of time spent" # # Returns the created Note object - def change_time_spent(noteable, project, author) time_spent = noteable.time_spent @@ -450,10 +448,6 @@ module SystemNoteService end end - def cross_reference?(note_text) - note_text =~ /\A#{cross_reference_note_prefix}/i - end - # Check if a cross-reference is disallowed # # This method prevents adding a "mentioned in !1" note on every single commit @@ -483,7 +477,6 @@ module SystemNoteService # mentioner - Mentionable object # # Returns Boolean - def cross_reference_exists?(noteable, mentioner) # Initial scope should be system notes of this noteable type notes = Note.system.where(noteable_type: noteable.class) diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index 18d0be3c103..b35d59bcf94 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -205,7 +205,7 @@ describe Projects::IssuesController do id: issue.iid, issue: { assignee_ids: [assignee.id] }, format: :json - body = JSON.parse(response.body) + body = json_response expect(body['assignees'].first.keys) .to match_array(%w(id name username avatar_url state web_url)) diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index 60477b8e9ba..77f422f3c53 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -503,20 +503,6 @@ describe SystemNoteService, services: true do end end - describe '.cross_reference?' do - it 'is truthy when text begins with expected text' do - expect(described_class.cross_reference?('mentioned in something')).to be_truthy - end - - it 'is truthy when text begins with legacy capitalized expected text' do - expect(described_class.cross_reference?('mentioned in something')).to be_truthy - end - - it 'is falsey when text does not begin with expected text' do - expect(described_class.cross_reference?('this is a note')).to be_falsey - end - end - describe '.cross_reference_disallowed?' do context 'when mentioner is not a MergeRequest' do it 'is falsey' do |