diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-09-22 18:08:05 +0300 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-10-24 09:03:38 +0300 |
commit | b803bc7bb8ad481790d01848902e80602e77da67 (patch) | |
tree | 912263f61ddfcf849380edf475942f4fdeca46cf /app/services | |
parent | cef10ef7d7a20a78d377f711867e361bb51fbaf2 (diff) |
Implement review comments from @DouweM.
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/protected_branches/api_create_service.rb | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/app/services/protected_branches/api_create_service.rb b/app/services/protected_branches/api_create_service.rb index a28056035b8..cbb99ede9f3 100644 --- a/app/services/protected_branches/api_create_service.rb +++ b/app/services/protected_branches/api_create_service.rb @@ -11,17 +11,22 @@ module ProtectedBranches end def execute - if @developers_can_push - @params.merge!(push_access_levels_attributes: [{ access_level: Gitlab::Access::DEVELOPER }]) - else - @params.merge!(push_access_levels_attributes: [{ access_level: Gitlab::Access::MASTER }]) - end + push_access_level = + if @developers_can_push + Gitlab::Access::DEVELOPER + else + Gitlab::Access::MASTER + end - if @developers_can_merge - @params.merge!(merge_access_levels_attributes: [{ access_level: Gitlab::Access::DEVELOPER }]) - else - @params.merge!(merge_access_levels_attributes: [{ access_level: Gitlab::Access::MASTER }]) - end + merge_access_level = + if @developers_can_merge + Gitlab::Access::DEVELOPER + else + Gitlab::Access::MASTER + end + + @params.merge!(push_access_levels_attributes: [{ access_level: push_access_level }], + merge_access_levels_attributes: [{ access_level: merge_access_level }]) service = ProtectedBranches::CreateService.new(@project, @current_user, @params) service.execute |