2021-12-01 04:10:25 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe Clusters::Agents::ActivityEventPolicy do
|
|
|
|
let_it_be(:event) { create(:agent_activity_event) }
|
|
|
|
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:policy) { described_class.new(user, event) }
|
|
|
|
let(:project) { event.agent.project }
|
|
|
|
|
|
|
|
describe 'rules' do
|
2022-01-27 19:14:06 -05:00
|
|
|
context 'reporter' do
|
|
|
|
before do
|
|
|
|
project.add_reporter(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(policy).to be_disallowed :admin_cluster }
|
|
|
|
it { expect(policy).to be_disallowed :read_cluster }
|
|
|
|
end
|
|
|
|
|
2021-12-01 04:10:25 -05:00
|
|
|
context 'developer' do
|
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(policy).to be_disallowed :admin_cluster }
|
2022-01-27 19:14:06 -05:00
|
|
|
it { expect(policy).to be_allowed :read_cluster }
|
2021-12-01 04:10:25 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'maintainer' do
|
|
|
|
before do
|
|
|
|
project.add_maintainer(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(policy).to be_allowed :admin_cluster }
|
|
|
|
it { expect(policy).to be_allowed :read_cluster }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|