diff options
-rw-r--r-- | app/workers/pages/deactivated_deployments_delete_cron_worker.rb | 1 | ||||
-rw-r--r-- | spec/workers/pages/deactivated_deployments_delete_cron_worker_spec.rb | 11 |
2 files changed, 8 insertions, 4 deletions
diff --git a/app/workers/pages/deactivated_deployments_delete_cron_worker.rb b/app/workers/pages/deactivated_deployments_delete_cron_worker.rb index 7ee6327cea7..75905759761 100644 --- a/app/workers/pages/deactivated_deployments_delete_cron_worker.rb +++ b/app/workers/pages/deactivated_deployments_delete_cron_worker.rb @@ -12,6 +12,7 @@ module Pages def perform PagesDeployment.deactivated.each_batch do |deployments| # rubocop: disable Style/SymbolProc + deployments.each { |deployment| deployment.file.remove! } deployments.delete_all end end diff --git a/spec/workers/pages/deactivated_deployments_delete_cron_worker_spec.rb b/spec/workers/pages/deactivated_deployments_delete_cron_worker_spec.rb index b4ee1d6b439..e2687e7cd9a 100644 --- a/spec/workers/pages/deactivated_deployments_delete_cron_worker_spec.rb +++ b/spec/workers/pages/deactivated_deployments_delete_cron_worker_spec.rb @@ -5,11 +5,14 @@ require 'spec_helper' RSpec.describe Pages::DeactivatedDeploymentsDeleteCronWorker, feature_category: :pages do subject(:worker) { described_class.new } - it 'deletes all deactivated pages deployments' do - create(:pages_deployment) # active - create(:pages_deployment, deleted_at: 3.minutes.ago) # deactivated - create(:pages_deployment, path_prefix: 'other', deleted_at: 3.minutes.ago) # deactivated + let!(:pages_deployment) { create(:pages_deployment) } + let!(:deactivated_pages_deployment) { create(:pages_deployment, deleted_at: 3.minutes.ago) } + let!(:alt_deactivated_pages_deployment) { create(:pages_deployment, path_prefix: 'other', deleted_at: 3.minutes.ago) } + + it 'deletes all deactivated pages deployments and their files from the filesystem' do + file_paths = [deactivated_pages_deployment.file.path, alt_deactivated_pages_deployment.file.path] expect { worker.perform }.to change { PagesDeployment.count }.by(-2) + .and change { (file_paths.any? { |path| File.exist?(path) }) }.from(true).to(false) end end |