protected_tag.rb 348 Bytes
Newer Older
1 2
# frozen_string_literal: true

3
class ProtectedTag < ActiveRecord::Base
4
  include ProtectedRef
5

Robert Schilling's avatar
Robert Schilling committed
6 7
  validates :name, uniqueness: { scope: :project_id }

8
  protected_ref_access_levels :create
9 10

  def self.protected?(project, ref_name)
11 12 13
    refs = project.protected_tags.select(:name)

    self.matching(ref_name, protected_refs: refs).present?
14
  end
15
end