system_keys_vacuum_spec.rb 624 B

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