diff options
Diffstat (limited to 'app/helpers/protected_branches_helper.rb')
-rw-r--r-- | app/helpers/protected_branches_helper.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/helpers/protected_branches_helper.rb b/app/helpers/protected_branches_helper.rb new file mode 100644 index 00000000000..07b07bfd33c --- /dev/null +++ b/app/helpers/protected_branches_helper.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module ProtectedBranchesHelper + def protected_branch_can_admin_entity?(protected_branch_entity) + if protected_branch_entity.is_a?(Group) + can?(current_user, :admin_group, protected_branch_entity) + else + can?(current_user, :admin_project, protected_branch_entity) + end + end + + def protected_branch_path_by_entity(protected_branch, protected_branch_entity) + if protected_branch_entity.is_a?(Group) + group_protected_branch_path(protected_branch_entity, protected_branch) + else + project_protected_branch_path(protected_branch_entity, protected_branch) + end + end +end |