Fixes various errors when adding deploy keys caused by not exiting the control flow.
What does this MR do?
Fixes regressions when adding deploy keys introduced in https://gitlab.com/gitlab-org/gitlab-ce/commit/2b6bd6a33f765175222cdb88cd927e420864a236.
When adding a deploy key that already exists in the project the existing key would not be returned, resulting in an attempt to create a new one, which in turn caused a 500 error due to an ActiveRecord exception.
When adding a deploy key that exists within another project the key would be joined to the project, but would also attempt to create a new one, which resulted in a 400 error due to the key already existing.
Are there points in the code the reviewer needs to double check?
Ruby is far from my forte. There may be a better way of exiting the control flow.
Why was this MR needed?
This regression is breaking the deployment process of several users.
Screenshots (if relevant)
Does this MR meet the acceptance criteria?
-
CHANGELOG entry added -
Documentation created/updated -
API support added - Tests
-
Added for this feature/bug -
All builds are passing
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Branch has no merge conflicts with master
(if it does - rebase it please) -
Squashed related commits together