2019-07-31 22:56:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe Clusters::InstancePolicy do
|
2019-07-31 22:56:46 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:policy) { described_class.new(user, Clusters::Instance.new) }
|
|
|
|
|
|
|
|
describe 'rules' do
|
|
|
|
context 'when user' do
|
|
|
|
it { expect(policy).to be_disallowed :read_cluster }
|
2019-10-12 21:52:04 +05:30
|
|
|
it { expect(policy).to be_disallowed :add_cluster }
|
|
|
|
it { expect(policy).to be_disallowed :create_cluster }
|
2019-07-31 22:56:46 +05:30
|
|
|
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-24 23:13:21 +05:30
|
|
|
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-07-31 22:56:46 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|