summaryrefslogtreecommitdiff
path: root/spec/policies
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-10-05 21:29:22 +0900
committerShinya Maeda <shinya@gitlab.com>2017-10-05 21:29:22 +0900
commitfe135fac68fab5e2a15e7aaa250ae91cd7fa4851 (patch)
tree576f7033950cb887b5c9013854a862bb12ae7485 /spec/policies
parentb229637b0837065a9993d06573b41218ab7e9dfb (diff)
downloadgitlab-ce-fe135fac68fab5e2a15e7aaa250ae91cd7fa4851.tar.gz
authorizations_controller_spec. cluster_policy_spec.
Diffstat (limited to 'spec/policies')
-rw-r--r--spec/policies/gcp/cluster_policy_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/policies/gcp/cluster_policy_spec.rb b/spec/policies/gcp/cluster_policy_spec.rb
new file mode 100644
index 00000000000..e213aa3d557
--- /dev/null
+++ b/spec/policies/gcp/cluster_policy_spec.rb
@@ -0,0 +1,28 @@
+require 'spec_helper'
+
+describe Gcp::ClusterPolicy, :models do
+ set(:project) { create(:project) }
+ set(:cluster) { create(:gcp_cluster, project: project) }
+ let(:user) { create(:user) }
+ let(:policy) { described_class.new(user, cluster) }
+
+ describe 'rules' do
+ context 'when developer' do
+ before do
+ project.add_developer(user)
+ end
+
+ it { expect(policy).to be_disallowed :update_cluster }
+ it { expect(policy).to be_disallowed :admin_cluster }
+ end
+
+ context 'when master' do
+ before do
+ project.add_master(user)
+ end
+
+ it { expect(policy).to be_allowed :update_cluster }
+ it { expect(policy).to be_allowed :admin_cluster }
+ end
+ end
+end