summaryrefslogtreecommitdiff
path: root/app/services/protected_branches
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-10-24 11:32:09 +0530
committerTimothy Andrew <mail@timothyandrew.net>2016-10-24 11:33:38 +0530
commitdb0182e261936c3e800b546d307a3d3834ff9927 (patch)
tree6c902ba70208a08ddf7eb4308a7d032634faa1e3 /app/services/protected_branches
parent1051087ac4efc3dbf45bd075e36af647d2b66d62 (diff)
downloadgitlab-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.rb10
-rw-r--r--app/services/protected_branches/api_update_service.rb7
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