Refactoring: Migrated Observer::Sla::TicketRebuildEscalation::BackgroundJob from Delayed::Job to Active Job.
This commit is contained in:
parent
b3cb67836d
commit
b370975a01
4 changed files with 19 additions and 9 deletions
6
app/jobs/sla_ticket_rebuild_escalation_job.rb
Normal file
6
app/jobs/sla_ticket_rebuild_escalation_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class SlaTicketRebuildEscalationJob < ApplicationJob
|
||||
def perform(_sla_id)
|
||||
Cache.delete('SLA::List::Active')
|
||||
Ticket::Escalation.rebuild_all
|
||||
end
|
||||
end
|
|
@ -13,7 +13,7 @@ class Observer::Sla::TicketRebuildEscalation < ActiveRecord::Observer
|
|||
Cache.delete('SLA::List::Active')
|
||||
|
||||
# send background job
|
||||
Delayed::Job.enqueue( Observer::Sla::TicketRebuildEscalation::BackgroundJob.new(record.id) )
|
||||
SlaTicketRebuildEscalationJob.perform_later(record.id)
|
||||
end
|
||||
|
||||
def _check(record)
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
class Observer::Sla::TicketRebuildEscalation::BackgroundJob
|
||||
def initialize(_sla_id); end
|
||||
|
||||
def perform
|
||||
Cache.delete('SLA::List::Active')
|
||||
Ticket::Escalation.rebuild_all
|
||||
end
|
||||
end
|
12
spec/jobs/sla_ticket_rebuild_escalation_job_spec.rb
Normal file
12
spec/jobs/sla_ticket_rebuild_escalation_job_spec.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe SlaTicketRebuildEscalationJob, type: :job do
|
||||
|
||||
it 'executes the job' do
|
||||
sla = create(:sla)
|
||||
|
||||
expect(Cache).to receive(:delete).with('SLA::List::Active')
|
||||
expect(Ticket::Escalation).to receive(:rebuild_all)
|
||||
described_class.perform_now(sla.id)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue