imap_authentication_migration_cleanup_job_spec.rb 784 B

1234567891011121314151617181920212223242526272829303132
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe ImapAuthenticationMigrationCleanupJob, type: :job do
  4. let(:migrated_at) { 8.days.ago }
  5. let(:channel) do
  6. channel = build(:channel, area: 'Google::Account')
  7. channel.options[:backup_imap_classic] = {
  8. backuphere: 1,
  9. migrated_at: migrated_at
  10. }
  11. channel.save!
  12. channel
  13. end
  14. it 'deletes obsolete classic IMAP backup' do
  15. expect { described_class.perform_now }.to change { channel.reload.options }
  16. end
  17. context 'recently migrated' do
  18. let(:migrated_at) { Time.zone.now }
  19. it 'keeps classic IMAP backup untouched' do
  20. expect { described_class.perform_now }.not_to change { channel.reload.options }
  21. end
  22. end
  23. end