2019-04-09 22:13:43 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe Clusters::InstancePolicy do
|
2019-04-09 22:13:43 -04:00
|
|
|
let(:user) { create(:user) }
|
2019-05-01 21:07:38 -04:00
|
|
|
let(:policy) { described_class.new(user, Clusters::Instance.new) }
|
2019-04-09 22:13:43 -04:00
|
|
|
|
|
|
|
describe 'rules' do
|
|
|
|
context 'when user' do
|
2019-04-17 22:45:31 -04:00
|
|
|
it { expect(policy).to be_disallowed :read_cluster }
|
2019-08-11 20:04:55 -04:00
|
|
|
it { expect(policy).to be_disallowed :add_cluster }
|
|
|
|
it { expect(policy).to be_disallowed :create_cluster }
|
2019-04-09 22:13:43 -04:00
|
|
|
it { expect(policy).to be_disallowed :update_cluster }
|
|
|
|
it { expect(policy).to be_disallowed :admin_cluster }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when admin' do
|
|
|
|
let(:user) { create(:admin) }
|
|
|
|
|
2020-05-15 11:08:04 -04:00
|
|
|
context 'when admin mode is enabled', :enable_admin_mode do
|
|
|
|
it { expect(policy).to be_allowed :read_cluster }
|
|
|
|
it { expect(policy).to be_allowed :add_cluster }
|
|
|
|
it { expect(policy).to be_allowed :create_cluster }
|
|
|
|
it { expect(policy).to be_allowed :update_cluster }
|
|
|
|
it { expect(policy).to be_allowed :admin_cluster }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when admin mode is disabled' do
|
|
|
|
it { expect(policy).to be_disallowed :read_cluster }
|
|
|
|
it { expect(policy).to be_disallowed :add_cluster }
|
|
|
|
it { expect(policy).to be_disallowed :create_cluster }
|
|
|
|
it { expect(policy).to be_disallowed :update_cluster }
|
|
|
|
it { expect(policy).to be_disallowed :admin_cluster }
|
|
|
|
end
|
2019-04-09 22:13:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|