summaryrefslogtreecommitdiff
path: root/lib/api/projects.rb
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2018-07-27 16:24:43 +0100
committerTiago Botelho <tiagonbotelho@hotmail.com>2018-07-27 16:24:43 +0100
commitd138a949dab359581f8beed92a5a2bcb692e6d5c (patch)
treeb5ed79e1117c190dc31c3c77aa6d8d5ab7425015 /lib/api/projects.rb
parentd9da5a984cdcc50c2d5cfb0ddacb3c5cd5c28d08 (diff)
downloadgitlab-ce-d138a949dab359581f8beed92a5a2bcb692e6d5c.tar.gz
Backports EE-1499 to CE
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r--lib/api/projects.rb67
1 files changed, 39 insertions, 28 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index eadde7b17bb..7adde79d6c3 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -13,6 +13,10 @@ module API
# EE::API::Projects would override this helper
end
+ params :optional_update_params_ee do
+ # EE::API::Projects would override this helper
+ end
+
# EE::API::Projects would override this method
def apply_filters(projects)
projects = projects.with_issues_available_for_user(current_user) if params[:with_issues_enabled]
@@ -21,6 +25,37 @@ module API
projects
end
+
+ def verify_update_project_attrs!(project, attrs)
+ end
+ end
+
+ def self.update_params_at_least_one_of
+ [
+ :jobs_enabled,
+ :resolve_outdated_diff_discussions,
+ :ci_config_path,
+ :container_registry_enabled,
+ :default_branch,
+ :description,
+ :issues_enabled,
+ :lfs_enabled,
+ :merge_requests_enabled,
+ :merge_method,
+ :name,
+ :only_allow_merge_if_all_discussions_are_resolved,
+ :only_allow_merge_if_pipeline_succeeds,
+ :path,
+ :printing_merge_request_link_enabled,
+ :public_builds,
+ :request_access_enabled,
+ :shared_runners_enabled,
+ :snippets_enabled,
+ :tag_list,
+ :visibility,
+ :wiki_enabled,
+ :avatar
+ ]
end
helpers do
@@ -252,39 +287,13 @@ module API
success Entities::Project
end
params do
- # CE
- at_least_one_of_ce =
- [
- :jobs_enabled,
- :resolve_outdated_diff_discussions,
- :ci_config_path,
- :container_registry_enabled,
- :default_branch,
- :description,
- :issues_enabled,
- :lfs_enabled,
- :merge_requests_enabled,
- :merge_method,
- :name,
- :only_allow_merge_if_all_discussions_are_resolved,
- :only_allow_merge_if_pipeline_succeeds,
- :path,
- :printing_merge_request_link_enabled,
- :public_builds,
- :request_access_enabled,
- :shared_runners_enabled,
- :snippets_enabled,
- :tag_list,
- :visibility,
- :wiki_enabled,
- :avatar
- ]
optional :name, type: String, desc: 'The name of the project'
optional :default_branch, type: String, desc: 'The default branch of the project'
optional :path, type: String, desc: 'The path of the repository'
use :optional_project_params
- at_least_one_of(*at_least_one_of_ce)
+
+ at_least_one_of(*::API::Projects.update_params_at_least_one_of)
end
put ':id' do
authorize_admin_project
@@ -294,6 +303,8 @@ module API
attrs = translate_params_for_compatibility(attrs)
+ verify_update_project_attrs!(user_project, attrs)
+
result = ::Projects::UpdateService.new(user_project, current_user, attrs).execute
if result[:status] == :success