diff --git a/ee/app/models/concerns/ee/protected_ref.rb b/ee/app/models/concerns/ee/protected_ref.rb index bd5ba832aa1b09ab374a00951ec8c75451611869..71b6a35a606aa0dd2952ae1c8d40117fc13749c6 100644 --- a/ee/app/models/concerns/ee/protected_ref.rb +++ b/ee/app/models/concerns/ee/protected_ref.rb @@ -4,17 +4,9 @@ module ProtectedRef class_methods do def protected_ref_access_levels(*types) - types.each do |type| - # We need to set `inverse_of` to make sure the `belongs_to`-object is set - # when creating children using `accepts_nested_attributes_for`. - # - # If we don't `protected_branch` or `protected_tag` would be empty and - # `project` cannot be delegated to it, which in turn would cause validations - # to fail. - has_many :"#{type}_access_levels", inverse_of: self.model_name.singular # rubocop:disable Cop/ActiveRecordDependent - - accepts_nested_attributes_for :"#{type}_access_levels", allow_destroy: true + super + types.each do |type| # Overwrite the validation for access levels # # EE Needs to allow more access levels in the relation: