Refactoring: SLA id paramater for SlaTicketRebuildEscalationJob is never used.

This commit is contained in:
Thorsten Eckel 2019-10-11 22:48:40 +02:00
parent c8d19fc0af
commit 3667cacab0
3 changed files with 11 additions and 8 deletions

View file

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

View file

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

View file

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