summaryrefslogtreecommitdiff
path: root/spec/workers/clusters/cleanup/service_account_worker_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/workers/clusters/cleanup/service_account_worker_spec.rb')
-rw-r--r--spec/workers/clusters/cleanup/service_account_worker_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/workers/clusters/cleanup/service_account_worker_spec.rb b/spec/workers/clusters/cleanup/service_account_worker_spec.rb
new file mode 100644
index 00000000000..9af53dd63c1
--- /dev/null
+++ b/spec/workers/clusters/cleanup/service_account_worker_spec.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Clusters::Cleanup::ServiceAccountWorker do
+ describe '#perform' do
+ let!(:cluster) { create(:cluster, :cleanup_removing_service_account) }
+
+ context 'when cluster.cleanup_status is cleanup_removing_service_account' do
+ it 'calls Clusters::Cleanup::ServiceAccountService' do
+ expect_any_instance_of(Clusters::Cleanup::ServiceAccountService).to receive(:execute).once
+
+ subject.perform(cluster.id)
+ end
+ end
+
+ context 'when cluster.cleanup_status is not cleanup_removing_service_account' do
+ let!(:cluster) { create(:cluster, :with_environments) }
+
+ it 'does not call Clusters::Cleanup::ServiceAccountService' do
+ expect(Clusters::Cleanup::ServiceAccountService).not_to receive(:new)
+
+ subject.perform(cluster.id)
+ end
+ end
+ end
+end