summaryrefslogtreecommitdiff
path: root/spec/policies/clusters/agent_policy_spec.rb
blob: 307d751b78b14ce99ee156f60a0d330c789b3065 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Clusters::AgentPolicy do
  let(:cluster_agent) { create(:cluster_agent, name: 'agent' )}
  let(:user) { create(:admin) }
  let(:policy) { described_class.new(user, cluster_agent) }
  let(:project) { cluster_agent.project }

  describe 'rules' do
    context 'when developer' do
      before do
        project.add_developer(user)
      end

      it { expect(policy).to be_disallowed :admin_cluster }
    end

    context 'when maintainer' do
      before do
        project.add_maintainer(user)
      end

      it { expect(policy).to be_allowed :admin_cluster }
    end
  end
end