Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2019-03-13 16:38:28 +0300
committerJohn Jarvis <jarv@gitlab.com>2019-03-13 16:41:57 +0300
commitb2d300f3b7fe5afba0a353e4364c6e379c2211be (patch)
treee17472c6811c213a2da28b1754995f9ad7346c73
parentd5fa495b8b3f0f9aed4af43987b17a80c8e3e5e6 (diff)
Merge branch 'sh-fix-blank-codeowners-ce' into 'master'
Fix 500 error caused by CODEOWNERS with no matches Closes gitlab-ee#10282 See merge request gitlab-org/gitlab-ce!26072
-rw-r--r--changelogs/unreleased/sh-fix-blank-codeowners-ce.yml5
-rw-r--r--lib/gitlab/user_extractor.rb1
-rw-r--r--spec/lib/gitlab/user_extractor_spec.rb8
3 files changed, 14 insertions, 0 deletions
diff --git a/changelogs/unreleased/sh-fix-blank-codeowners-ce.yml b/changelogs/unreleased/sh-fix-blank-codeowners-ce.yml
new file mode 100644
index 00000000000..05ea5869eb1
--- /dev/null
+++ b/changelogs/unreleased/sh-fix-blank-codeowners-ce.yml
@@ -0,0 +1,5 @@
+---
+title: Fix 500 error caused by CODEOWNERS with no matches
+merge_request: 26072
+author:
+type: fixed
diff --git a/lib/gitlab/user_extractor.rb b/lib/gitlab/user_extractor.rb
index 874599688bb..b41d085ee77 100644
--- a/lib/gitlab/user_extractor.rb
+++ b/lib/gitlab/user_extractor.rb
@@ -16,6 +16,7 @@ module Gitlab
def users
return User.none unless @text.present?
+ return User.none if references.empty?
@users ||= User.from_union(union_relations)
end
diff --git a/spec/lib/gitlab/user_extractor_spec.rb b/spec/lib/gitlab/user_extractor_spec.rb
index fcc05ab3a0c..6e2bb81fbda 100644
--- a/spec/lib/gitlab/user_extractor_spec.rb
+++ b/spec/lib/gitlab/user_extractor_spec.rb
@@ -48,6 +48,14 @@ describe Gitlab::UserExtractor do
it 'includes all mentioned usernames' do
expect(extractor.matches[:usernames]).to contain_exactly('user-1', 'user-2', 'user-4')
end
+
+ context 'input has no matching e-mail or usernames' do
+ it 'returns an empty list of users' do
+ extractor = described_class.new('My test')
+
+ expect(extractor.users).to be_empty
+ end
+ end
end
describe '#references' do