Change AutoArchiveProcedureWorker for delayed_job
This commit is contained in:
parent
b9869d861f
commit
fbad15bc84
2 changed files with 11 additions and 2 deletions
|
@ -1,7 +1,6 @@
|
|||
class AutoArchiveProcedureWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
def perform(*args)
|
||||
Rails.logger.info("AutoArchiveProcedureWorker started at #{Time.now}")
|
||||
Procedure.publiees.where("auto_archive_on <= ?", Date.today).each do |procedure|
|
||||
procedure.dossiers.state_en_construction.each do |dossier|
|
||||
dossier.received!
|
||||
|
@ -9,5 +8,12 @@ class AutoArchiveProcedureWorker
|
|||
|
||||
procedure.archive
|
||||
end
|
||||
Rails.logger.info("AutoArchiveProcedureWorker ended at #{Time.now}")
|
||||
end
|
||||
|
||||
def queue_name
|
||||
"cron"
|
||||
end
|
||||
|
||||
handle_asynchronously :perform
|
||||
end
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AutoArchiveProcedureWorker, type: :worker do
|
||||
before { Delayed::Worker.delay_jobs = false }
|
||||
after { Delayed::Worker.delay_jobs = true }
|
||||
|
||||
let!(:procedure) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: nil )}
|
||||
let!(:procedure_hier) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: 1.day.ago )}
|
||||
let!(:procedure_aujourdhui) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: Date.today )}
|
||||
|
|
Loading…
Reference in a new issue