Skip to content

Commit

Permalink
Rename SaveToCloudStorageWorker
Browse files Browse the repository at this point in the history
`Sidekiq::Worker` has been deprecated in Sidekiq 7, so we need to
replace it with `Sidekiq::Job`, and then rename the workers to be jobs.
  • Loading branch information
brucebolt committed Sep 24, 2024
1 parent 5eb7305 commit b759c9f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/models/asset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Asset
end

after_transition to: :clean do |asset, _|
SaveToCloudStorageWorker.perform_async(asset.id.to_s)
SaveToCloudStorageJob.perform_async(asset.id.to_s)
end

event :scanned_infected do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "services"

class SaveToCloudStorageWorker
include Sidekiq::Worker
class SaveToCloudStorageJob
include Sidekiq::Job

def perform(asset_id)
asset = Asset.undeleted.find(asset_id)
Expand Down
6 changes: 3 additions & 3 deletions spec/models/asset_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@
let(:asset) { FactoryBot.build(:asset, state:) }

before do
allow(SaveToCloudStorageWorker).to receive(:perform_async)
allow(SaveToCloudStorageJob).to receive(:perform_async)
end

it "sets the asset state to clean" do
Expand All @@ -513,7 +513,7 @@
end

it "schedules saving the asset to cloud storage" do
expect(SaveToCloudStorageWorker).to receive(:perform_async).with(asset.id)
expect(SaveToCloudStorageJob).to receive(:perform_async).with(asset.id)

asset.scanned_clean!
end
Expand Down Expand Up @@ -551,7 +551,7 @@
let(:asset) { FactoryBot.build(:asset, state:) }

it "does not schedule saving the asset to cloud storage" do
expect(SaveToCloudStorageWorker).not_to receive(:perform_async).with(asset.id)
expect(SaveToCloudStorageJob).not_to receive(:perform_async).with(asset.id)

asset.scanned_infected!
end
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/virus_scanning_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
get download_media_path(id: asset, filename: "lorem.txt")
expect(response).to have_http_status(:not_found)

SaveToCloudStorageWorker.drain
SaveToCloudStorageJob.drain

get download_media_path(id: asset, filename: "lorem.txt")
expect(response).to have_http_status(:found)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "rails_helper"

RSpec.describe SaveToCloudStorageWorker, type: :worker do
RSpec.describe SaveToCloudStorageJob, type: :worker do
let(:worker) { described_class.new }

describe "#perform" do
Expand Down

0 comments on commit b759c9f

Please sign in to comment.