diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-07-07 10:36:28 +0300 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-07-29 12:50:39 +0300 |
commit | 134fe5af83167f95205a080f7932452de7d77496 (patch) | |
tree | 6f253ad95afc8fc0525c6501ce9345294dd1ff45 /app/services/protected_branches/update_service.rb | |
parent | 21bece443d5f871680a3d7649c2d16861035196d (diff) |
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`
Diffstat (limited to 'app/services/protected_branches/update_service.rb')
-rw-r--r-- | app/services/protected_branches/update_service.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/services/protected_branches/update_service.rb b/app/services/protected_branches/update_service.rb new file mode 100644 index 00000000000..ed59b06b79a --- /dev/null +++ b/app/services/protected_branches/update_service.rb @@ -0,0 +1,21 @@ +module ProtectedBranches + class UpdateService < BaseService + attr_reader :protected_branch + + def initialize(project, current_user, id, params = {}) + super(project, current_user, params) + @id = id + end + + def execute + ProtectedBranch.transaction do + @protected_branch = ProtectedBranch.find(@id) + set_access_levels! + end + + true + rescue ActiveRecord::RecordInvalid + false + end + end +end |