backups_vacuum_spec.rb 653 B

123456789101112131415161718192021222324
  1. require 'rails_helper'
  2. RSpec.describe Vacuum::BackupsVacuum do
  3. let(:retention_period) { 7.days }
  4. subject { described_class.new(retention_period) }
  5. describe '#perform' do
  6. let!(:expired_backup) { Fabricate(:backup, created_at: (retention_period + 1.day).ago) }
  7. let!(:current_backup) { Fabricate(:backup) }
  8. before do
  9. subject.perform
  10. end
  11. it 'deletes backups past the retention period' do
  12. expect { expired_backup.reload }.to raise_error ActiveRecord::RecordNotFound
  13. end
  14. it 'does not delete backups within the retention period' do
  15. expect { current_backup.reload }.to_not raise_error
  16. end
  17. end
  18. end