Merge branch '29673-500-internal-server-error-when-enabling-a-deploy-key-more-than-once-through-api' into 'master'
Detect already enabled DeployKeys in EnableDeployKeyService Closes #29673 See merge request !11010
This commit is contained in:
commit
349e423137
3 changed files with 18 additions and 1 deletions
|
@ -4,7 +4,10 @@ module Projects
|
||||||
key = accessible_keys.find_by(id: params[:key_id] || params[:id])
|
key = accessible_keys.find_by(id: params[:key_id] || params[:id])
|
||||||
return unless key
|
return unless key
|
||||||
|
|
||||||
|
unless project.deploy_keys.include?(key)
|
||||||
project.deploy_keys << key
|
project.deploy_keys << key
|
||||||
|
end
|
||||||
|
|
||||||
key
|
key
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
title: Detect already enabled DeployKeys in EnableDeployKeyService
|
||||||
|
merge_request:
|
||||||
|
author:
|
|
@ -21,6 +21,16 @@ describe Projects::EnableDeployKeyService, services: true do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'add the same key twice' do
|
||||||
|
before do
|
||||||
|
project.deploy_keys << deploy_key
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns existing key' do
|
||||||
|
expect(service.execute).to eq(deploy_key)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def service
|
def service
|
||||||
Projects::EnableDeployKeyService.new(project, user, params)
|
Projects::EnableDeployKeyService.new(project, user, params)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue