summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2019-08-27 21:03:02 +0200
committerJan Provaznik <jprovaznik@gitlab.com>2019-08-27 21:03:02 +0200
commit74a06feb22f1e10856e449be192f64ce9b830057 (patch)
tree87b359f7782abb51b452da6e2255a42c5a5ed9d2
parent27c222d16ccb666878c7ac558f484efa56f77f37 (diff)
downloadgitlab-ce-dangerfile-fix.tar.gz
Dangerfile: Handle missing area in roledangerfile-fix
It's possible that area is not present in a role, then we should handle `nil` value too.
-rw-r--r--lib/gitlab/danger/teammate.rb4
-rw-r--r--spec/lib/gitlab/danger/teammate_spec.rb13
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/gitlab/danger/teammate.rb b/lib/gitlab/danger/teammate.rb
index 8ae4ffdadb0..2789706aa3b 100644
--- a/lib/gitlab/danger/teammate.rb
+++ b/lib/gitlab/danger/teammate.rb
@@ -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
diff --git a/spec/lib/gitlab/danger/teammate_spec.rb b/spec/lib/gitlab/danger/teammate_spec.rb
index 61b43e343c1..e0c1298fa13 100644
--- a/spec/lib/gitlab/danger/teammate_spec.rb
+++ b/spec/lib/gitlab/danger/teammate_spec.rb
@@ -50,6 +50,19 @@ 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
+
+ it '#maintainer? returns false' do
+ expect(subject.maintainer?(project, :test, labels)).to be_falsey
+ end
+ end
+
+
context 'when role is Test Automation Engineer, Manage' do
let(:role) { 'Test Automation Engineer, Manage' }