BigW Consortium Gitlab

build_policy.rb 410 Bytes
Newer Older
1 2 3
module Ci
  class BuildPolicy < CommitStatusPolicy
    def rules
4 5
      can! :read_build if @subject.project.public_builds?

6 7 8 9
      super

      # If we can't read build we should also not have that
      # ability when looking at this in context of commit_status
10
      %w[read create update admin].each do |rule|
11 12 13 14 15
        cannot! :"#{rule}_commit_status" unless can? :"#{rule}_build"
      end
    end
  end
end