diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-01-16 21:03:42 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-01-16 21:03:42 +0400 |
commit | 1d2bdb4d5880bb1ad39b62c81ff2971aa0cb3798 (patch) | |
tree | 8ac3215b2c25cb57b5f2198fd4d85c7bad968c2b /app/services/projects/update_service.rb | |
parent | dba982403b7b894d2096ea61b89a247060eefe57 (diff) |
Move all Context classes into Services
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/services/projects/update_service.rb')
-rw-r--r-- | app/services/projects/update_service.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/services/projects/update_service.rb b/app/services/projects/update_service.rb new file mode 100644 index 00000000000..d9d371da5c4 --- /dev/null +++ b/app/services/projects/update_service.rb @@ -0,0 +1,19 @@ +module Projects + class UpdateService < BaseService + def execute(role = :default) + params[:project].delete(:namespace_id) + # check that user is allowed to set specified visibility_level + unless can?(current_user, :change_visibility_level, project) && Gitlab::VisibilityLevel.allowed_for?(current_user, params[:project][:visibility_level]) + params[:project].delete(:visibility_level) + end + + new_branch = params[:project].delete(:default_branch) + + if project.repository.exists? && new_branch && new_branch != project.default_branch + project.change_head(new_branch) + end + + project.update_attributes(params[:project], as: role) + end + end +end |