ticket_escalation_rebuild_job_spec.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe TicketEscalationRebuildJob, type: :job do
  4. before do
  5. travel_to(DateTime.parse('2013-03-21 09:30:00 UTC'))
  6. end
  7. context 'when relevant Ticket is present' do
  8. subject(:ticket) { create(:ticket) }
  9. before do
  10. create(:sla, :condition_blank, first_response_time: 60, update_time: 120, solution_time: 180)
  11. create(:'ticket/article', :inbound_email, ticket: ticket)
  12. ticket.update_column(:escalation_at, 2.hours.ago)
  13. travel(1.hour)
  14. end
  15. it 'en-force-es new escalation calculation' do
  16. expect { described_class.perform_now }.to change { ticket.reload.escalation_at }
  17. end
  18. end
  19. context 'when not relevant Ticket is present' do
  20. subject(:ticket) { create(:ticket) }
  21. before do
  22. create(:'ticket/article', :inbound_email, ticket: ticket)
  23. ticket.update_column(:escalation_at, 2.hours.ago)
  24. travel(1.hour)
  25. end
  26. it 'does not not change escalation_at' do
  27. expect { described_class.perform_now }.to change { ticket.reload.escalation_at }
  28. end
  29. end
  30. end