backups_vacuum_spec.rb 684 B

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