2019-03-06 11:00:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-05-29 10:38:26 -04:00
|
|
|
require 'fast_spec_helper'
|
|
|
|
|
|
|
|
require 'gitlab/danger/teammate'
|
|
|
|
|
2019-03-06 11:00:27 -05:00
|
|
|
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
|
2019-05-29 10:38:26 -04:00
|
|
|
expect(subject.reviewer?(project, :backend)).to be_truthy
|
2019-03-06 11:00:27 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it '#traintainer? supports multiple roles per project' do
|
2019-05-29 10:38:26 -04:00
|
|
|
expect(subject.traintainer?(project, :database)).to be_truthy
|
2019-03-06 11:00:27 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it '#maintainer? supports multiple roles per project' do
|
2019-05-29 10:38:26 -04:00
|
|
|
expect(subject.maintainer?(project, :frontend)).to be_truthy
|
2019-03-06 11:00:27 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'one role project project' do
|
|
|
|
let(:capabilities) { 'reviewer backend' }
|
|
|
|
|
|
|
|
it '#reviewer? supports one role per project' do
|
2019-05-29 10:38:26 -04:00
|
|
|
expect(subject.reviewer?(project, :backend)).to be_truthy
|
2019-03-06 11:00:27 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it '#traintainer? supports one role per project' do
|
2019-05-29 10:38:26 -04:00
|
|
|
expect(subject.traintainer?(project, :database)).to be_falsey
|
2019-03-06 11:00:27 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it '#maintainer? supports one role per project' do
|
2019-05-29 10:38:26 -04:00
|
|
|
expect(subject.maintainer?(project, :frontend)).to be_falsey
|
2019-03-06 11:00:27 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|