cebcc417ed
1. Instantiate `ProtectedBranchesAccessSelect` from `dispatcher` 2. Use `can?(user, ...)` instead of `user.can?(...)` 3. Add `DOWNTIME` notes to all migrations added in !5081. 4. Add an explicit `down` method for migrations removing the `developers_can_push` and `developers_can_merge` columns, ensuring that the columns created (on rollback) have the appropriate defaults. 5. Remove duplicate CHANGELOG entries. 6. Blank lines after guard clauses.
24 lines
693 B
Ruby
24 lines
693 B
Ruby
class ProtectedBranch::MergeAccessLevel < ActiveRecord::Base
|
|
belongs_to :protected_branch
|
|
delegate :project, to: :protected_branch
|
|
|
|
validates :access_level, presence: true, inclusion: { in: [Gitlab::Access::MASTER,
|
|
Gitlab::Access::DEVELOPER] }
|
|
|
|
def self.human_access_levels
|
|
{
|
|
Gitlab::Access::MASTER => "Masters",
|
|
Gitlab::Access::DEVELOPER => "Developers + Masters"
|
|
}.with_indifferent_access
|
|
end
|
|
|
|
def check_access(user)
|
|
return true if user.is_admin?
|
|
|
|
project.team.max_member_access(user.id) >= access_level
|
|
end
|
|
|
|
def humanize
|
|
self.class.human_access_levels[self.access_level]
|
|
end
|
|
end
|