ticket_escalation_rebuild_job_spec.rb 1.0 KB

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