From 00f51a6ccf945ba3d174bb63598fccc1df67be1f Mon Sep 17 00:00:00 2001 From: James Edwards-Jones Date: Fri, 25 Aug 2017 16:09:49 +0000 Subject: [PATCH] EE::ProtectedRef inherits has_many and accepts_nested_attributes_for --- ee/app/models/concerns/ee/protected_ref.rb | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/ee/app/models/concerns/ee/protected_ref.rb b/ee/app/models/concerns/ee/protected_ref.rb index bd5ba832aa1b09..71b6a35a606aa0 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: -- GitLab