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

Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
Rémy Coutable 2019-08-27 19:13:55 +02:00
parent ca5724be5d
commit e17ba8d9e3
No known key found for this signature in database
GPG key ID: 98DFFD1C0C62B70B
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' }