Merge branch 'fix-nil-error-in-gitlab-danger-teammate' into 'master'

Fix a nil error in Gitlab::Danger::Teammate

See merge request gitlab-org/gitlab-ce!32284
This commit is contained in:
Lin Jen-Shin 2019-08-27 19:01:09 +00:00
commit 4eecb0ad96
2 changed files with 10 additions and 2 deletions

View file

@ -39,9 +39,9 @@ module Gitlab
def has_capability?(project, category, kind, labels)
case category
when :test
area = role[/Test Automation Engineer(?:.*?, (\w+))/, 1].downcase
area = role[/Test Automation Engineer(?:.*?, (\w+))/, 1]
area && labels.any?("devops::#{area}") if kind == :reviewer
area && labels.any?("devops::#{area.downcase}") if kind == :reviewer
else
capabilities(project).include?("#{kind} #{category}")
end

View file

@ -50,6 +50,14 @@ describe Gitlab::Danger::Teammate do
end
end
context 'when role is Test Automation Engineer' do
let(:role) { 'Test Automation Engineer' }
it '#reviewer? returns false' do
expect(subject.reviewer?(project, :test, labels)).to be_falsey
end
end
context 'when role is Test Automation Engineer, Manage' do
let(:role) { 'Test Automation Engineer, Manage' }