Reduce factory creation (132 -> 40) in lib/vacuum/* specs (#32498)

This commit is contained in:
Matt Jankowski 2024-10-15 08:54:56 -04:00 committed by Claire
parent 0c59ef44b1
commit 2d008108a4
6 changed files with 41 additions and 58 deletions

View file

@ -11,16 +11,13 @@ RSpec.describe Vacuum::BackupsVacuum do
let!(:expired_backup) { Fabricate(:backup, created_at: (retention_period + 1.day).ago) }
let!(:current_backup) { Fabricate(:backup) }
before do
it 'deletes backups past the retention period but preserves those within the period' do
subject.perform
end
it 'deletes backups past the retention period' do
expect { expired_backup.reload }.to raise_error ActiveRecord::RecordNotFound
end
it 'does not delete backups within the retention period' do
expect { current_backup.reload }.to_not raise_error
expect { expired_backup.reload }
.to raise_error ActiveRecord::RecordNotFound
expect { current_backup.reload }
.to_not raise_error
end
end
end