system_keys_vacuum_spec.rb 593 B

12345678910111213141516171819202122
  1. require 'rails_helper'
  2. RSpec.describe Vacuum::SystemKeysVacuum do
  3. subject { described_class.new }
  4. describe '#perform' do
  5. let!(:expired_system_key) { Fabricate(:system_key, created_at: (SystemKey::ROTATION_PERIOD * 4).ago) }
  6. let!(:current_system_key) { Fabricate(:system_key) }
  7. before do
  8. subject.perform
  9. end
  10. it 'deletes the expired key' do
  11. expect { expired_system_key.reload }.to raise_error ActiveRecord::RecordNotFound
  12. end
  13. it 'does not delete the current key' do
  14. expect { current_system_key.reload }.to_not raise_error
  15. end
  16. end
  17. end