trabajo-afectivo/spec/jobs/imap_authentication_migration_cleanup_job_spec.rb

33 lines
784 B
Ruby
Raw Permalink Normal View History

2022-01-01 13:38:12 +00:00
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
require 'rails_helper'
RSpec.describe ImapAuthenticationMigrationCleanupJob, type: :job do
let(:migrated_at) { 8.days.ago }
let(:channel) do
channel = build(:channel, area: 'Google::Account')
channel.options[:backup_imap_classic] = {
backuphere: 1,
migrated_at: migrated_at
}
channel.save!
channel
end
it 'deletes obsolete classic IMAP backup' do
expect { described_class.perform_now }.to change { channel.reload.options }
end
context 'recently migrated' do
let(:migrated_at) { Time.zone.now }
it 'keeps classic IMAP backup untouched' do
expect { described_class.perform_now }.not_to change { channel.reload.options }
end
end
end