summaryrefslogtreecommitdiff
path: root/spec/presenters
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2017-12-06 09:07:52 +0000
committerGrzegorz Bizon <grzegorz@gitlab.com>2017-12-06 09:07:52 +0000
commit29c243b08d91194d46203a085f6857fe966bcdff (patch)
treeee2f443ce026ce271fc579a6933d0f572a64ac87 /spec/presenters
parent67a94b2ff3b0d714549c7d30b3c6212f3046a3c2 (diff)
parent0ef16b272002013bbdb44517e62f0a1d15046cf5 (diff)
downloadgitlab-ce-29c243b08d91194d46203a085f6857fe966bcdff.tar.gz
Merge branch 'list-multiple-clusters' into 'master'
List multiple clusters See merge request gitlab-org/gitlab-ce!15403
Diffstat (limited to 'spec/presenters')
-rw-r--r--spec/presenters/clusters/cluster_presenter_spec.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/presenters/clusters/cluster_presenter_spec.rb b/spec/presenters/clusters/cluster_presenter_spec.rb
index 48d4f3671c5..e96dbfb73c0 100644
--- a/spec/presenters/clusters/cluster_presenter_spec.rb
+++ b/spec/presenters/clusters/cluster_presenter_spec.rb
@@ -31,4 +31,44 @@ describe Clusters::ClusterPresenter do
it { is_expected.to include(cluster.provider.zone) }
it { is_expected.to include(cluster.name) }
end
+
+ describe '#can_toggle_cluster' do
+ let(:user) { create(:user) }
+
+ before do
+ allow(cluster).to receive(:current_user).and_return(user)
+ end
+
+ subject { described_class.new(cluster).can_toggle_cluster? }
+
+ context 'when user can update' do
+ before do
+ allow_any_instance_of(described_class).to receive(:can?).with(user, :update_cluster, cluster).and_return(true)
+ end
+
+ context 'when cluster is created' do
+ before do
+ allow(cluster).to receive(:created?).and_return(true)
+ end
+
+ it { is_expected.to eq(true) }
+ end
+
+ context 'when cluster is not created' do
+ before do
+ allow(cluster).to receive(:created?).and_return(false)
+ end
+
+ it { is_expected.to eq(false) }
+ end
+ end
+
+ context 'when user can not update' do
+ before do
+ allow_any_instance_of(described_class).to receive(:can?).with(user, :update_cluster, cluster).and_return(false)
+ end
+
+ it { is_expected.to eq(false) }
+ end
+ end
end