diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2019-07-30 22:29:02 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2019-07-30 22:29:02 +0800 |
commit | 0c7e13f912847fe5fb7eeb93c1cfd4861d6ec44e (patch) | |
tree | 1851ea6a1f36f7092d9d6f6335a1e1f6f6c35375 | |
parent | ab509c78929d9b5f4e02d013e8911ac9d0a07aad (diff) | |
download | gitlab-ce-0c7e13f912847fe5fb7eeb93c1cfd4861d6ec44e.tar.gz |
Update regular expression to extract stage name
Since now the role name can be:
"<a href=\"/job-families/engineering/test-automation-engineer/\">Senior Test Automation Engineer</a>, Create:Source Code"
We need to cope with </a> in the middle.
-rw-r--r-- | lib/gitlab/danger/teammate.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/danger/teammate_spec.rb | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/gitlab/danger/teammate.rb b/lib/gitlab/danger/teammate.rb index b44f134f2c1..74cbcc11255 100644 --- a/lib/gitlab/danger/teammate.rb +++ b/lib/gitlab/danger/teammate.rb @@ -39,7 +39,7 @@ module Gitlab def has_capability?(project, category, kind, labels) case category when :test - area = role[/Test Automation Engineer, (\w+)/, 1] + area = role[/Test Automation Engineer(?:.*?, (\w+))/, 1] area && labels.any?(area) if kind == :reviewer else diff --git a/spec/lib/gitlab/danger/teammate_spec.rb b/spec/lib/gitlab/danger/teammate_spec.rb index 6a6cf1429c8..171f2344e82 100644 --- a/spec/lib/gitlab/danger/teammate_spec.rb +++ b/spec/lib/gitlab/danger/teammate_spec.rb @@ -40,6 +40,14 @@ describe Gitlab::Danger::Teammate do it '#maintainer? returns false' do expect(subject.maintainer?(project, :test, labels)).to be_falsey end + + context 'when hyperlink is mangled in the role' do + let(:role) { '<a href="#">Test Automation Engineer</a>, Create' } + + it '#reviewer? returns true' do + expect(subject.reviewer?(project, :test, labels)).to be_truthy + end + end end context 'when role is Test Automation Engineer, Manage' do |