From 134fe5af83167f95205a080f7932452de7d77496 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Thu, 7 Jul 2016 13:06:28 +0530 Subject: Use the `{Push,Merge}AccessLevel` models in the UI. 1. Improve error handling while creating protected branches. 2. Modify coffeescript code so that the "Developers can *" checkboxes send a '1' or '0' even when using AJAX. This lets us keep the backend code simpler. 3. Use services for both creating and updating protected branches. Destruction is taken care of with `dependent: :destroy` --- app/services/protected_branches/base_service.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 app/services/protected_branches/base_service.rb (limited to 'app/services/protected_branches/base_service.rb') diff --git a/app/services/protected_branches/base_service.rb b/app/services/protected_branches/base_service.rb new file mode 100644 index 00000000000..d4be8698a5f --- /dev/null +++ b/app/services/protected_branches/base_service.rb @@ -0,0 +1,17 @@ +module ProtectedBranches + class BaseService < ::BaseService + def set_access_levels! + if params[:developers_can_push] == '0' + @protected_branch.push_access_level.masters! + elsif params[:developers_can_push] == '1' + @protected_branch.push_access_level.developers! + end + + if params[:developers_can_merge] == '0' + @protected_branch.merge_access_level.masters! + elsif params[:developers_can_merge] == '1' + @protected_branch.merge_access_level.developers! + end + end + end +end -- cgit v1.2.3