diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-10-24 11:32:09 +0530 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-10-24 11:33:38 +0530 |
commit | db0182e261936c3e800b546d307a3d3834ff9927 (patch) | |
tree | 6c902ba70208a08ddf7eb4308a7d032634faa1e3 /app/services/protected_branches | |
parent | 1051087ac4efc3dbf45bd075e36af647d2b66d62 (diff) | |
download | gitlab-ce-db0182e261936c3e800b546d307a3d3834ff9927.tar.gz |
Implement third round of review comments from @DouweM.21513-fix-branch-protection-api
Extract/mutate `params` in the `execute` method of the API services,
rather than in `initialize`.
Diffstat (limited to 'app/services/protected_branches')
-rw-r--r-- | app/services/protected_branches/api_create_service.rb | 10 | ||||
-rw-r--r-- | app/services/protected_branches/api_update_service.rb | 7 |
2 files changed, 4 insertions, 13 deletions
diff --git a/app/services/protected_branches/api_create_service.rb b/app/services/protected_branches/api_create_service.rb index d714a8aaf01..f2040dfa03a 100644 --- a/app/services/protected_branches/api_create_service.rb +++ b/app/services/protected_branches/api_create_service.rb @@ -4,22 +4,16 @@ # lives in this service. module ProtectedBranches class ApiCreateService < BaseService - def initialize(project, user, params) - @developers_can_merge = params.delete(:developers_can_merge) - @developers_can_push = params.delete(:developers_can_push) - super(project, user, params) - end - def execute push_access_level = - if @developers_can_push + if params.delete(:developers_can_push) Gitlab::Access::DEVELOPER else Gitlab::Access::MASTER end merge_access_level = - if @developers_can_merge + if params.delete(:developers_can_merge) Gitlab::Access::DEVELOPER else Gitlab::Access::MASTER diff --git a/app/services/protected_branches/api_update_service.rb b/app/services/protected_branches/api_update_service.rb index c28bffee2f4..050cb3b738b 100644 --- a/app/services/protected_branches/api_update_service.rb +++ b/app/services/protected_branches/api_update_service.rb @@ -4,13 +4,10 @@ # lives in this service. module ProtectedBranches class ApiUpdateService < BaseService - def initialize(project, user, params) - @developers_can_merge = params.delete(:developers_can_merge) + def execute(protected_branch) @developers_can_push = params.delete(:developers_can_push) - super(project, user, params) - end + @developers_can_merge = params.delete(:developers_can_merge) - def execute(protected_branch) @protected_branch = protected_branch protected_branch.transaction do |