Commit b7e5f73c authored by Matija Čupić's avatar Matija Čupić

Raise exception when user is not authorized

parent 0bc14b45
......@@ -3,7 +3,7 @@
module Ci
class DestroyPipelineService < BaseService
def execute(pipeline)
return false unless can?(current_user, :destroy_pipeline, pipeline)
raise Gitlab::Access::AccessDeniedError unless can?(current_user, :destroy_pipeline, pipeline)
AuditEventService.new(current_user, pipeline).security_event
......
......@@ -53,14 +53,8 @@ describe ::Ci::DestroyPipelineService do
context 'user is not owner' do
let(:user) { create(:user) }
it 'returns false' do
is_expected.to eq(false)
end
it 'does not destroy the pipeline' do
subject
expect { pipeline.reload }.not_to raise_error
it 'raises an exception' do
expect { subject }.to raise_error(Gitlab::Access::AccessDeniedError)
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