Commit a6c477ec authored by Serena Fang's avatar Serena Fang

Reduce flaky tests by looking for author id

parent ea584e6b
......@@ -101,7 +101,7 @@ RSpec.describe ResourceAccessTokens::CreateService do
it 'logs the permission error message' do
subject
expect(AuditEvent.last.details[:custom_message]).to eq('Attempted to create project access token but failed with message: User does not have permission to create project access token')
expect(AuditEvent.where(author_id: user.id).last.details[:custom_message]).to eq('Attempted to create project access token but failed with message: User does not have permission to create project access token')
end
end
......@@ -123,7 +123,7 @@ RSpec.describe ResourceAccessTokens::CreateService do
it 'logs the provisioning error message' do
subject
expect(AuditEvent.last.details[:custom_message]).to eq('Attempted to create project access token but failed with message: Could not provision maintainer access to project access token')
expect(AuditEvent.where(author_id: user.id).last.details[:custom_message]).to eq('Attempted to create project access token but failed with message: Could not provision maintainer access to project access token')
end
end
end
......
......@@ -56,7 +56,7 @@ RSpec.describe ResourceAccessTokens::RevokeService do
it 'logs the find error message' do
subject
expect(AuditEvent.last.details[:custom_message]).to match(/Attempted to revoke project access token with id: \d+, but failed with message: Failed to find bot user/)
expect(AuditEvent.where(author_id: user.id).last.details[:custom_message]).to match(/Attempted to revoke project access token with id: \d+, but failed with message: Failed to find bot user/)
end
end
......@@ -71,7 +71,7 @@ RSpec.describe ResourceAccessTokens::RevokeService do
it 'logs the permission error message' do
subject
expect(AuditEvent.last.details[:custom_message]).to match(/Attempted to revoke project access token with id: \d+, but failed with message: #{user.name} cannot delete #{access_token.user.name}/)
expect(AuditEvent.where(author_id: user.id).last.details[:custom_message]).to match(/Attempted to revoke project access token with id: \d+, but failed with message: #{user.name} cannot delete #{access_token.user.name}/)
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment