Fix ProcessReferencesWorker error for tasks before update
This commit is contained in:
parent
2f21aa5193
commit
75c0e512f4
3 changed files with 21 additions and 4 deletions
|
@ -46,7 +46,7 @@ class ProcessReferencesService < BaseService
|
|||
return unless need_process?(status, reference_parameters, urls)
|
||||
|
||||
Rails.cache.write("status_reference:#{status.id}", true, expires_in: 10.minutes)
|
||||
ProcessReferencesWorker.perform_async(status.id, reference_parameters, urls, [])
|
||||
ProcessReferencesWorker.perform_async(status.id, reference_parameters, urls, no_fetch_urls: [])
|
||||
end
|
||||
|
||||
def self.call_service(status, reference_parameters, urls)
|
||||
|
@ -133,6 +133,6 @@ class ProcessReferencesService < BaseService
|
|||
end
|
||||
|
||||
def launch_worker
|
||||
ProcessReferencesWorker.perform_async(@status.id, @reference_parameters, @urls, @no_fetch_urls)
|
||||
ProcessReferencesWorker.perform_async(@status.id, @reference_parameters, @urls, no_fetch_urls: @no_fetch_urls)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
class ProcessReferencesWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
def perform(status_id, ids, urls, no_fetch_urls)
|
||||
ProcessReferencesService.new.call(Status.find(status_id), ids || [], urls: urls || [], no_fetch_urls: no_fetch_urls)
|
||||
def perform(status_id, ids, urls, no_fetch_urls: nil)
|
||||
ProcessReferencesService.new.call(Status.find(status_id), ids || [], urls: urls || [], no_fetch_urls: no_fetch_urls || [])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
true
|
||||
end
|
||||
|
|
17
spec/workers/process_references_worker_spec.rb
Normal file
17
spec/workers/process_references_worker_spec.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ProcessReferencesWorker do
|
||||
let(:worker) { described_class.new }
|
||||
|
||||
describe 'perform' do
|
||||
it 'runs without error for simple call' do
|
||||
expect { worker.perform(1000, [], []) }.to_not raise_error
|
||||
end
|
||||
|
||||
it 'runs without error with no_fetch_urls' do
|
||||
expect { worker.perform(1000, [], [], no_fetch_urls: []) }.to_not raise_error
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue