diff options
author | Rémy Coutable <remy@rymai.me> | 2018-04-23 10:04:10 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-04-23 10:04:10 +0000 |
commit | eb1cb7bed6951bdda54abd55e86fd793e6954a56 (patch) | |
tree | b79e556c7d38f0350493f689624acf1e257c5283 /lib | |
parent | c8129d797548e6b9450b384873e04fa94663e0ce (diff) | |
parent | 5716167775280e5a830443ccb095e2879814f783 (diff) | |
download | gitlab-ce-eb1cb7bed6951bdda54abd55e86fd793e6954a56.tar.gz |
Merge branch '45576-fix-create-project-for-user-endpoint' into 'master'
Resolve "Upgrading to API V4 Project Creation for user Fails"
Closes #45576
See merge request gitlab-org/gitlab-ce!18518
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/projects.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 51b3b0459f3..8871792060b 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -74,6 +74,11 @@ module API present options[:with].prepare_relation(projects, options), options end + + def translate_params_for_compatibility(params) + params[:builds_enabled] = params.delete(:jobs_enabled) if params.key?(:jobs_enabled) + params + end end resource :users, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do @@ -123,7 +128,7 @@ module API end post do attrs = declared_params(include_missing: false) - attrs[:builds_enabled] = attrs.delete(:jobs_enabled) if attrs.key?(:jobs_enabled) + attrs = translate_params_for_compatibility(attrs) project = ::Projects::CreateService.new(current_user, attrs).execute if project.saved? @@ -155,6 +160,7 @@ module API not_found!('User') unless user attrs = declared_params(include_missing: false) + attrs = translate_params_for_compatibility(attrs) project = ::Projects::CreateService.new(user, attrs).execute if project.saved? @@ -276,7 +282,7 @@ module API authorize! :rename_project, user_project if attrs[:name].present? authorize! :change_visibility_level, user_project if attrs[:visibility].present? - attrs[:builds_enabled] = attrs.delete(:jobs_enabled) if attrs.key?(:jobs_enabled) + attrs = translate_params_for_compatibility(attrs) result = ::Projects::UpdateService.new(user_project, current_user, attrs).execute |