summaryrefslogtreecommitdiff
path: root/app/models/concerns/protected_ref_access.rb
blob: 42fa066b7cf522b04c5379f0400884fd6ff5be80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module ProtectedRefAccess
  extend ActiveSupport::Concern

  included do
    # belongs_to :protected_branch
    # delegate :project, to: :protected_branch

    scope :master, -> { where(access_level: Gitlab::Access::MASTER) }
    scope :developer, -> { where(access_level: Gitlab::Access::DEVELOPER) }
  end

  def humanize
    self.class.human_access_levels[self.access_level]
  end

  def check_access(user)
    return true if user.is_admin?

    project.team.max_member_access(user.id) >= access_level
  end
end