Commit 903132bc authored by Douwe Maan's avatar Douwe Maan

Merge branch 'fix-ext-issue-webbased-hooks' into 'master'

Fix hooks for web based events with external issue references

The creation of cross references for external issues (which would fail)
is now prevented. This fixes a 500 error and the execution of hooks when
creating a merge request or commenting on one.

Fixes #1650, GH-9333.

This regression might have been introduced by
8f8a8ab3. There is actually a TODO by
@rspeicher mentioning external issues which is lost (unhandled) in a
later commit.

This fix is related to !766 and !804 which fix a similar issue for hooks for
Git based events.

See merge request !794
parents 5fa02489 92bb845e
...@@ -9,6 +9,7 @@ v 7.13.0 (unreleased) ...@@ -9,6 +9,7 @@ v 7.13.0 (unreleased)
v 7.12.0 (unreleased) v 7.12.0 (unreleased)
- Fix post-receive errors on a push when an external issue tracker is configured (Stan Hu) - Fix post-receive errors on a push when an external issue tracker is configured (Stan Hu)
- Update oauth button logos for Twitter and Google to recommended assets - 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) - Update browser gem to version 0.8.0 for IE11 support (Stan Hu)
- Fix timeout when rendering file with thousands of lines. - Fix timeout when rendering file with thousands of lines.
- Add "Remember me" checkbox to LDAP signin form. - Add "Remember me" checkbox to LDAP signin form.
......
...@@ -212,13 +212,15 @@ class SystemNoteService ...@@ -212,13 +212,15 @@ class SystemNoteService
# Check if a cross-reference is disallowed # Check if a cross-reference is disallowed
# #
# This method prevents adding a "mentioned in !1" note on every single commit # 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 # noteable - Noteable object being referenced
# mentioner - Mentionable object # mentioner - Mentionable object
# #
# Returns Boolean # Returns Boolean
def self.cross_reference_disallowed?(noteable, mentioner) def self.cross_reference_disallowed?(noteable, mentioner)
return true if noteable.is_a?(ExternalIssue)
return false unless mentioner.is_a?(MergeRequest) return false unless mentioner.is_a?(MergeRequest)
return false unless noteable.is_a?(Commit) return false unless noteable.is_a?(Commit)
......
...@@ -338,6 +338,15 @@ describe SystemNoteService do ...@@ -338,6 +338,15 @@ describe SystemNoteService do
to be_falsey to be_falsey
end end
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 end
describe '.cross_reference_exists?' do describe '.cross_reference_exists?' do
......
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