Commit 7f0ec9d8 authored by Andreas Brandl's avatar Andreas Brandl

Support multiple roulette roles per project

parent 97357c5b
...@@ -21,21 +21,21 @@ module Gitlab ...@@ -21,21 +21,21 @@ module Gitlab
# Traintainers also count as reviewers # Traintainers also count as reviewers
def reviewer?(project, category) def reviewer?(project, category)
capabilities(project) == "reviewer #{category}" || traintainer?(project, category) capabilities(project).include?("reviewer #{category}") || traintainer?(project, category)
end end
def traintainer?(project, category) def traintainer?(project, category)
capabilities(project) == "trainee_maintainer #{category}" capabilities(project).include?("trainee_maintainer #{category}")
end end
def maintainer?(project, category) def maintainer?(project, category)
capabilities(project) == "maintainer #{category}" capabilities(project).include?("maintainer #{category}")
end end
private private
def capabilities(project) def capabilities(project)
projects.fetch(project, '') Array(projects.fetch(project, []))
end end
end end
end end
......
# frozen_string_literal: true
describe Gitlab::Danger::Teammate do
subject { described_class.new({ 'projects' => projects }) }
let(:projects) { { project => capabilities } }
let(:project) { double }
describe 'multiple roles project project' do
let(:capabilities) { ['reviewer backend', 'maintainer frontend', 'trainee_maintainer database'] }
it '#reviewer? supports multiple roles per project' do
expect(subject.reviewer?(project, 'backend')).to be_truthy
end
it '#traintainer? supports multiple roles per project' do
expect(subject.traintainer?(project, 'database')).to be_truthy
end
it '#maintainer? supports multiple roles per project' do
expect(subject.maintainer?(project, 'frontend')).to be_truthy
end
end
describe 'one role project project' do
let(:capabilities) { 'reviewer backend' }
it '#reviewer? supports one role per project' do
expect(subject.reviewer?(project, 'backend')).to be_truthy
end
it '#traintainer? supports one role per project' do
expect(subject.traintainer?(project, 'database')).to be_falsey
end
it '#maintainer? supports one role per project' do
expect(subject.maintainer?(project, 'frontend')).to be_falsey
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment