diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-07 21:10:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-07 21:10:36 +0300 |
commit | 39d41e02dca2139d0bbd88165affd818c9c82fb6 (patch) | |
tree | 4fb80e74a677eb672ec82e151648605f2d2afd47 /app/models/concerns/protected_ref.rb | |
parent | f276d294878605e289c84beb53032b40c53ba961 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/concerns/protected_ref.rb')
-rw-r--r-- | app/models/concerns/protected_ref.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/concerns/protected_ref.rb b/app/models/concerns/protected_ref.rb index cddca72f91f..65195a8d5aa 100644 --- a/app/models/concerns/protected_ref.rb +++ b/app/models/concerns/protected_ref.rb @@ -12,6 +12,10 @@ module ProtectedRef delegate :matching, :matches?, :wildcard?, to: :ref_matcher scope :for_project, ->(project) { where(project: project) } + + def allow_multiple?(type) + false + end end def commit @@ -29,7 +33,7 @@ module ProtectedRef # to fail. has_many :"#{type}_access_levels", inverse_of: self.model_name.singular - validates :"#{type}_access_levels", length: { is: 1, message: "are restricted to a single instance per #{self.model_name.human}." } + validates :"#{type}_access_levels", length: { is: 1, message: "are restricted to a single instance per #{self.model_name.human}." }, unless: -> { allow_multiple?(type) } accepts_nested_attributes_for :"#{type}_access_levels", allow_destroy: true end |