Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-08 15:06:32 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-08 15:06:32 +0300
commit61f0c58946ebac453b55a657cd4be1ac50a01e11 (patch)
tree7b164c1cc9dc8ab1d100ca4fe90decf6d72e984b /spec/services/clusters
parentd23b2a0871f3ca507aafa949e0314625f1f0c6a7 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/clusters')
-rw-r--r--spec/services/clusters/destroy_service_spec.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/services/clusters/destroy_service_spec.rb b/spec/services/clusters/destroy_service_spec.rb
new file mode 100644
index 00000000000..c0fcc971500
--- /dev/null
+++ b/spec/services/clusters/destroy_service_spec.rb
@@ -0,0 +1,56 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Clusters::DestroyService do
+ describe '#execute' do
+ subject { described_class.new(cluster.user, params).execute(cluster) }
+
+ let!(:cluster) { create(:cluster, :project, :provided_by_user) }
+
+ context 'when correct params' do
+ shared_examples 'only removes cluster' do
+ it 'does not start cleanup' do
+ expect(cluster).not_to receive(:start_cleanup)
+ subject
+ end
+
+ it 'destroys the cluster' do
+ subject
+ expect { cluster.reload }.to raise_error ActiveRecord::RecordNotFound
+ end
+ end
+
+ context 'when params are empty' do
+ let(:params) { {} }
+
+ it_behaves_like 'only removes cluster'
+ end
+
+ context 'when cleanup param is false' do
+ let(:params) { { cleanup: 'false' } }
+
+ it_behaves_like 'only removes cluster'
+ end
+
+ context 'when cleanup param is true' do
+ let(:params) { { cleanup: 'true' } }
+
+ before do
+ allow(Clusters::Cleanup::AppWorker).to receive(:perform_async)
+ end
+
+ it 'does not destroy cluster' do
+ subject
+ expect(Clusters::Cluster.where(id: cluster.id).exists?).not_to be_falsey
+ end
+
+ it 'transition cluster#cleanup_status from cleanup_not_started to uninstalling_applications' do
+ expect { subject }.to change { cluster.cleanup_status_name }
+ .from(:cleanup_not_started)
+ .to(:cleanup_uninstalling_applications)
+ end
+ end
+ end
+ end
+end