Protected packages: Add enum for attr push_protected_up_to_access_level
requested to merge gitlab-community/gitlab:419957-protected-packages-convert-attribute-push_protected_up_to_access_level-to-enum into master
What does this MR do and why?
- This MR adds an enum for attribute
push_protected_up_to_access_level
- Adding this enum adds further model utilities that are helpful, make the code more readable and increases dev usability / productivity
- Note: This change is backward compatible as existing code related to this attribute still works
Screenshots or screen recordings
There are no visuals. This MR contains only backend -related changes.
How to set up and validate locally
- Open rails console
rails c
- Create as a
Packages::Protection::Rule
as we did before
ppr = Packages::Protection::Rule.create(project: Project.find(7),
package_type: :npm,
# With the enum the following values would be also fine:
# push_protected_up_to_access_level: :developer
# push_protected_up_to_access_level: "developer"
push_protected_up_to_access_level: Gitlab::Access::DEVELOPER,
package_name_pattern: "@gitlab-org/npm-package-new-enum-*")
- With the newly defined enum, we get additional utilities for "free"
# We get these method
ppr.push_protected_up_to_developer? # => true
ppr.push_protected_up_to_maintainer? # => false
# Values of this attribute are more readable instead of the number `30` for Gitlab::Access::DEVELOPER
ppr.push_protected_up_to_access_level # => "developer"
# etc.
Todos
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR. -
Changelog entry added, if necessary -
Documentation created/updated via this MR -
Documentation reviewed by technical writer or follow-up review issue created -
Tests added for this feature/bug -
Tested in all supported browsers -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the javascript style guides -
Conforms to the database guides
-
Related to #419957
Edited by Gerardo Navarro