access_tokens_vacuum_spec.rb 1001 B

123456789101112131415161718192021222324252627282930313233
  1. require 'rails_helper'
  2. RSpec.describe Vacuum::AccessTokensVacuum do
  3. subject { described_class.new }
  4. describe '#perform' do
  5. let!(:revoked_access_token) { Fabricate(:access_token, revoked_at: 1.minute.ago) }
  6. let!(:active_access_token) { Fabricate(:access_token) }
  7. let!(:revoked_access_grant) { Fabricate(:access_grant, revoked_at: 1.minute.ago) }
  8. let!(:active_access_grant) { Fabricate(:access_grant) }
  9. before do
  10. subject.perform
  11. end
  12. it 'deletes revoked access tokens' do
  13. expect { revoked_access_token.reload }.to raise_error ActiveRecord::RecordNotFound
  14. end
  15. it 'deletes revoked access grants' do
  16. expect { revoked_access_grant.reload }.to raise_error ActiveRecord::RecordNotFound
  17. end
  18. it 'does not delete active access tokens' do
  19. expect { active_access_token.reload }.to_not raise_error
  20. end
  21. it 'does not delete active access grants' do
  22. expect { active_access_grant.reload }.to_not raise_error
  23. end
  24. end
  25. end