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 GitHub
parent d74c2c583a
commit 0cc21f1ded
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 41 additions and 58 deletions

View file

@ -14,32 +14,24 @@ RSpec.describe Vacuum::AccessTokensVacuum do
let!(:expired_access_grant) { Fabricate(:access_grant, expires_in: 59.minutes.to_i, created_at: 1.hour.ago) }
let!(:active_access_grant) { Fabricate(:access_grant) }
before do
it 'deletes revoked/expired access tokens and revoked/expired grants, but preserves active tokens/grants' do
subject.perform
end
it 'deletes revoked access tokens' do
expect { revoked_access_token.reload }.to raise_error ActiveRecord::RecordNotFound
end
expect { revoked_access_token.reload }
.to raise_error ActiveRecord::RecordNotFound
expect { expired_access_token.reload }
.to raise_error ActiveRecord::RecordNotFound
it 'deletes expired access tokens' do
expect { expired_access_token.reload }.to raise_error ActiveRecord::RecordNotFound
end
expect { revoked_access_grant.reload }
.to raise_error ActiveRecord::RecordNotFound
expect { expired_access_grant.reload }
.to raise_error ActiveRecord::RecordNotFound
it 'deletes revoked access grants' do
expect { revoked_access_grant.reload }.to raise_error ActiveRecord::RecordNotFound
end
expect { active_access_token.reload }
.to_not raise_error
it 'deletes expired access grants' do
expect { expired_access_grant.reload }.to raise_error ActiveRecord::RecordNotFound
end
it 'does not delete active access tokens' do
expect { active_access_token.reload }.to_not raise_error
end
it 'does not delete active access grants' do
expect { active_access_grant.reload }.to_not raise_error
expect { active_access_grant.reload }
.to_not raise_error
end
end
end