active_job_lock_cleanup_job_spec.rb 731 B

1234567891011121314151617181920212223242526272829
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe ActiveJobLockCleanupJob, type: :job do
  4. context 'when ActiveJobLock records older than a day are present' do
  5. before do
  6. create(:active_job_lock, created_at: 1.day.ago)
  7. travel 1.minute
  8. end
  9. it 'cleans up those jobs' do
  10. expect { described_class.perform_now }.to change(ActiveJobLock, :count).by(-1)
  11. end
  12. end
  13. context 'when recent ActiveJobLock records are present' do
  14. before do
  15. create(:active_job_lock, created_at: 1.minute.ago)
  16. end
  17. it 'keeps those jobs' do
  18. expect { described_class.perform_now }.not_to change(ActiveJobLock, :count)
  19. end
  20. end
  21. end