taskbar_cleanup_job_spec.rb 739 B

123456789101112131415161718192021
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe TaskbarCleanupJob, type: :job do
  4. let(:taskbar_1) { create(:taskbar, app: :desktop, last_contact: 2.days.ago) }
  5. let(:taskbar_2) { create(:taskbar, app: :mobile, last_contact: 2.days.ago) }
  6. let(:taskbar_3) { create(:taskbar, app: :mobile, last_contact: 1.hour.ago) }
  7. before do
  8. taskbar_1.update_columns last_contact: 1.day.ago
  9. taskbar_2.update_columns last_contact: 1.day.ago
  10. taskbar_3.update_columns last_contact: 1.hour.ago
  11. end
  12. it 'removes old mobile taskbar only' do
  13. expect { described_class.perform_now }
  14. .to change { Taskbar.all.reload }
  15. .to eq([taskbar_1, taskbar_3])
  16. end
  17. end