diff options
author | Daniel Gerhardt <code@dgerhardt.net> | 2015-06-14 17:41:11 +0200 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-06-16 14:54:14 +0200 |
commit | 565f8f3ee4d0ee60082c5f927df2a249f94fad2a (patch) | |
tree | bca918d27abbd37dfe4fb4c8b12729c60147f92b | |
parent | cbeaa57a4afff922a7cacd5a10d1b25c7492a1f8 (diff) | |
download | gitlab-ce-ext-issue-7-12.tar.gz |
Fix hooks for web based events with external issue referencesext-issue-7-12
The creation of cross references for external issues (which would fail)
is now prevented.
Fixes #1650, GH-9333.
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/services/system_note_service.rb | 4 | ||||
-rw-r--r-- | spec/services/system_note_service_spec.rb | 9 |
3 files changed, 13 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG index 9d558b15ab9..64a91e7e513 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date. v 7.12.0 (unreleased) - Update oauth button logos for Twitter and Google to recommended assets + - Fix hooks for web based events with external issue references (Daniel Gerhardt) - Update browser gem to version 0.8.0 for IE11 support (Stan Hu) - Fix timeout when rendering file with thousands of lines. - Add "Remember me" checkbox to LDAP signin form. diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb index b6801a92330..8253c1f780d 100644 --- a/app/services/system_note_service.rb +++ b/app/services/system_note_service.rb @@ -212,13 +212,15 @@ class SystemNoteService # Check if a cross-reference is disallowed # # This method prevents adding a "mentioned in !1" note on every single commit - # in a merge request. + # in a merge request. Additionally, it prevents the creation of references to + # external issues (which would fail). # # noteable - Noteable object being referenced # mentioner - Mentionable object # # Returns Boolean def self.cross_reference_disallowed?(noteable, mentioner) + return true if noteable.is_a?(ExternalIssue) return false unless mentioner.is_a?(MergeRequest) return false unless noteable.is_a?(Commit) diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index 700286b585a..2658576640c 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -338,6 +338,15 @@ describe SystemNoteService do to be_falsey end end + + context 'when notable is an ExternalIssue' do + let(:noteable) { ExternalIssue.new('EXT-1234', project) } + it 'is truthy' do + mentioner = noteable.dup + expect(described_class.cross_reference_disallowed?(noteable, mentioner)). + to be_truthy + end + end end describe '.cross_reference_exists?' do |