2022-05-07 20:08:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
RSpec.describe Groups::DeployTokens::RevokeService, feature_category: :deployment_management do
|
2022-05-07 20:08:51 +05:30
|
|
|
let_it_be(:entity) { create(:group) }
|
|
|
|
let_it_be(:deploy_token) { create(:deploy_token, :group, groups: [entity]) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:deploy_token_params) { { id: deploy_token.id } }
|
|
|
|
|
|
|
|
describe '#execute' do
|
|
|
|
subject { described_class.new(entity, user, deploy_token_params).execute }
|
|
|
|
|
|
|
|
it "revokes a group deploy token" do
|
|
|
|
expect(deploy_token.revoked).to eq(false)
|
|
|
|
|
|
|
|
expect { subject }.to change { deploy_token.reload.revoked }.to eq(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'invalid token id' do
|
|
|
|
let(:deploy_token_params) { { token_id: non_existing_record_id } }
|
|
|
|
|
|
|
|
it 'raises an error' do
|
|
|
|
expect { subject }.to raise_error(ActiveRecord::RecordNotFound)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|