Refactoring: Migrated Observer::Sla::TicketRebuildEscalation::BackgroundJob from Delayed::Job to Active Job.

This commit is contained in:
Rolf Schmidt 2019-01-24 16:00:59 +01:00 committed by Thorsten Eckel
parent b3cb67836d
commit b370975a01
4 changed files with 19 additions and 9 deletions

View file

@ -0,0 +1,6 @@
class SlaTicketRebuildEscalationJob < ApplicationJob
def perform(_sla_id)
Cache.delete('SLA::List::Active')
Ticket::Escalation.rebuild_all
end
end

View file

@ -13,7 +13,7 @@ class Observer::Sla::TicketRebuildEscalation < ActiveRecord::Observer
Cache.delete('SLA::List::Active') Cache.delete('SLA::List::Active')
# send background job # send background job
Delayed::Job.enqueue( Observer::Sla::TicketRebuildEscalation::BackgroundJob.new(record.id) ) SlaTicketRebuildEscalationJob.perform_later(record.id)
end end
def _check(record) def _check(record)

View file

@ -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

View 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