diff --git a/app/models/asset.rb b/app/models/asset.rb index f53c6147..f0c0b983 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb @@ -108,7 +108,7 @@ class Asset after_transition to: :uploaded do |asset, _| asset.save! - DeleteAssetFileFromNfsWorker.perform_in(5.minutes, asset.id.to_s) + DeleteAssetFileFromNfsJob.perform_in(5.minutes, asset.id.to_s) end end diff --git a/app/workers/delete_asset_file_from_nfs_worker.rb b/app/sidekiq/delete_asset_file_from_nfs_job.rb similarity index 56% rename from app/workers/delete_asset_file_from_nfs_worker.rb rename to app/sidekiq/delete_asset_file_from_nfs_job.rb index d87f04f5..103080d1 100644 --- a/app/workers/delete_asset_file_from_nfs_worker.rb +++ b/app/sidekiq/delete_asset_file_from_nfs_job.rb @@ -1,12 +1,12 @@ -class DeleteAssetFileFromNfsWorker - include Sidekiq::Worker +class DeleteAssetFileFromNfsJob + include Sidekiq::Job sidekiq_options queue: "low_priority" def perform(asset_id) asset = Asset.find(asset_id) if asset.uploaded? FileUtils.rm_rf(File.dirname(asset.file.path)) - Rails.logger.info("#{asset.id} - DeleteAssetFileFromNfsWorker - File removed") + Rails.logger.info("#{asset.id} - DeleteAssetFileFromNfsJob - File removed") end end end diff --git a/config/brakeman.ignore b/config/brakeman.ignore index a71ec30b..fb1efd5b 100644 --- a/config/brakeman.ignore +++ b/config/brakeman.ignore @@ -13,7 +13,7 @@ "render_path": null, "location": { "type": "method", - "class": "DeleteAssetFileFromNfsWorker", + "class": "DeleteAssetFileFromNfsJob", "method": "perform" }, "user_input": "Asset.find(asset_id).file", diff --git a/lib/tasks/govuk_assets.rake b/lib/tasks/govuk_assets.rake index 8b6addfb..38c4fa7d 100644 --- a/lib/tasks/govuk_assets.rake +++ b/lib/tasks/govuk_assets.rake @@ -5,7 +5,7 @@ namespace :govuk_assets do task delete_file_from_nfs_for_assets_uploaded_to_s3: :environment do processor = AssetProcessor.new(scope: Asset.where(state: "uploaded")) processor.process_all_assets_with do |asset_id| - DeleteAssetFileFromNfsWorker.perform_async(asset_id.to_s) + DeleteAssetFileFromNfsJob.perform_async(asset_id.to_s) end end diff --git a/spec/models/asset_spec.rb b/spec/models/asset_spec.rb index d62bcf11..4970541b 100644 --- a/spec/models/asset_spec.rb +++ b/spec/models/asset_spec.rb @@ -1153,7 +1153,7 @@ end it "triggers the delete asset file worker" do - expect(DeleteAssetFileFromNfsWorker).to receive(:perform_in) + expect(DeleteAssetFileFromNfsJob).to receive(:perform_in) asset.upload_success! end end diff --git a/spec/workers/delete_asset_file_from_nfs_worker_spec.rb b/spec/sidekiq/delete_asset_file_from_nfs_job_spec.rb similarity index 93% rename from spec/workers/delete_asset_file_from_nfs_worker_spec.rb rename to spec/sidekiq/delete_asset_file_from_nfs_job_spec.rb index 8b6840af..95eaa42f 100644 --- a/spec/workers/delete_asset_file_from_nfs_worker_spec.rb +++ b/spec/sidekiq/delete_asset_file_from_nfs_job_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe DeleteAssetFileFromNfsWorker, type: :worker do +RSpec.describe DeleteAssetFileFromNfsJob, type: :worker do subject(:worker) { described_class.new } let(:asset) { FactoryBot.create(:asset, state:) }