-
- Downloads
Use `Gitlab::Access` to protected branch access levels.
1. It makes sense to reuse these constants since we had them duplicated in the previous enum implementation. This also simplifies our `check_access` implementation, because we can use `project.team.max_member_access` directly. 2. Use `accepts_nested_attributes_for` to create push/merge access levels. This was a bit fiddly to set up, but this simplifies our code by quite a large amount. We can even get rid of `ProtectedBranches::BaseService`. 3. Move API handling back into the API (previously in `ProtectedBranches::BaseService#translate_api_params`. 4. The protected branch services now return a `ProtectedBranch` rather than `true/false`. 5. Run `load_protected_branches` on-demand in the `create` action, to prevent it being called unneccessarily. 6. "Masters" is pre-selected as the default option for "Allowed to Push" and "Allowed to Merge". 7. These changes were based on a review from @rymai in !5081.
Showing
- app/assets/javascripts/protected_branches_access_select.js.es6 14 additions, 4 deletions...ssets/javascripts/protected_branches_access_select.js.es6
- app/controllers/projects/protected_branches_controller.rb 19 additions, 12 deletionsapp/controllers/projects/protected_branches_controller.rb
- app/models/protected_branch.rb 3 additions, 8 deletionsapp/models/protected_branch.rb
- app/models/protected_branch/merge_access_level.rb 5 additions, 11 deletionsapp/models/protected_branch/merge_access_level.rb
- app/models/protected_branch/push_access_level.rb 8 additions, 13 deletionsapp/models/protected_branch/push_access_level.rb
- app/services/git_push_service.rb 10 additions, 3 deletionsapp/services/git_push_service.rb
- app/services/protected_branches/base_service.rb 0 additions, 67 deletionsapp/services/protected_branches/base_service.rb
- app/services/protected_branches/create_service.rb 12 additions, 8 deletionsapp/services/protected_branches/create_service.rb
- app/services/protected_branches/update_service.rb 5 additions, 14 deletionsapp/services/protected_branches/update_service.rb
- app/views/projects/protected_branches/_branches_list.html.haml 1 addition, 1 deletion...iews/projects/protected_branches/_branches_list.html.haml
- app/views/projects/protected_branches/_protected_branch.html.haml 2 additions, 2 deletions...s/projects/protected_branches/_protected_branch.html.haml
- app/views/projects/protected_branches/index.html.haml 7 additions, 7 deletionsapp/views/projects/protected_branches/index.html.haml
- db/migrate/20160705054938_add_protected_branches_push_access.rb 3 additions, 1 deletion...rate/20160705054938_add_protected_branches_push_access.rb
- db/migrate/20160705054952_add_protected_branches_merge_access.rb 3 additions, 1 deletion...ate/20160705054952_add_protected_branches_merge_access.rb
- db/schema.rb 8 additions, 8 deletionsdb/schema.rb
- lib/api/branches.rb 27 additions, 9 deletionslib/api/branches.rb
- lib/api/entities.rb 2 additions, 2 deletionslib/api/entities.rb
- spec/factories/protected_branches.rb 11 additions, 5 deletionsspec/factories/protected_branches.rb
- spec/features/protected_branches_spec.rb 6 additions, 6 deletionsspec/features/protected_branches_spec.rb
- spec/services/git_push_service_spec.rb 6 additions, 6 deletionsspec/services/git_push_service_spec.rb
Please register or sign in to comment