backups_vacuum_spec.rb 645 B

1234567891011121314151617181920212223
  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. it 'deletes backups past the retention period but preserves those within the period' do
  10. subject.perform
  11. expect { expired_backup.reload }
  12. .to raise_error ActiveRecord::RecordNotFound
  13. expect { current_backup.reload }
  14. .to_not raise_error
  15. end
  16. end
  17. end