From 3667cacab064753859a9a30152a276893d19894f Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Fri, 11 Oct 2019 22:48:40 +0200 Subject: [PATCH] Refactoring: SLA id paramater for SlaTicketRebuildEscalationJob is never used. --- app/jobs/sla_ticket_rebuild_escalation_job.rb | 2 +- app/models/observer/sla/ticket_rebuild_escalation.rb | 6 +++--- spec/jobs/sla_ticket_rebuild_escalation_job_spec.rb | 11 +++++++---- 3 files changed, 11 insertions(+), 8 deletions(-) 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