diff --git a/app/jobs/sla_ticket_rebuild_escalation_job.rb b/app/jobs/sla_ticket_rebuild_escalation_job.rb index cb8f7e997..9070f5058 100644 --- a/app/jobs/sla_ticket_rebuild_escalation_job.rb +++ b/app/jobs/sla_ticket_rebuild_escalation_job.rb @@ -1,5 +1,5 @@ class SlaTicketRebuildEscalationJob < ApplicationJob - def perform(_sla_id) + def perform Cache.delete('SLA::List::Active') Ticket::Escalation.rebuild_all end diff --git a/app/models/observer/sla/ticket_rebuild_escalation.rb b/app/models/observer/sla/ticket_rebuild_escalation.rb index f1d644c3a..ea323c230 100644 --- a/app/models/observer/sla/ticket_rebuild_escalation.rb +++ b/app/models/observer/sla/ticket_rebuild_escalation.rb @@ -6,16 +6,16 @@ class Observer::Sla::TicketRebuildEscalation < ActiveRecord::Observer def after_commit(record) return if _check(record) - _rebuild(record) + _rebuild end private - def _rebuild(record) + def _rebuild Cache.delete('SLA::List::Active') # send background job - SlaTicketRebuildEscalationJob.perform_later(record.id) + SlaTicketRebuildEscalationJob.perform_later end def _check(record) diff --git a/spec/jobs/sla_ticket_rebuild_escalation_job_spec.rb b/spec/jobs/sla_ticket_rebuild_escalation_job_spec.rb index 5e73b554a..ff80cd7ce 100644 --- a/spec/jobs/sla_ticket_rebuild_escalation_job_spec.rb +++ b/spec/jobs/sla_ticket_rebuild_escalation_job_spec.rb @@ -2,11 +2,14 @@ require 'rails_helper' RSpec.describe SlaTicketRebuildEscalationJob, type: :job do - it 'executes the job' do - sla = create(:sla) - + it 'clears the SLA Cache' do + allow(Cache).to receive(:delete) expect(Cache).to receive(:delete).with('SLA::List::Active') + described_class.perform_now + end + + it 'triggers Ticket::Escalation rebuild' do expect(Ticket::Escalation).to receive(:rebuild_all) - described_class.perform_now(sla.id) + described_class.perform_now end end