diff options
author | Fabio Papa <fabtheman@gmail.com> | 2019-06-29 02:12:54 +0300 |
---|---|---|
committer | Fabio Papa <fabtheman@gmail.com> | 2019-07-19 23:00:05 +0300 |
commit | f1fcd64fb7f4dc19ebab44829dc66a5a8f28a096 (patch) | |
tree | ec53828258fdaa628df75fdb9e6689647ebfad3d | |
parent | 45668ed02370b617d2f8538d61eaa58bda6e39ca (diff) |
Make maintainers the default setting for creating subgroups
-rw-r--r-- | app/models/group.rb | 10 | ||||
-rw-r--r-- | spec/models/group_spec.rb | 8 |
2 files changed, 14 insertions, 4 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index 3f80c1373f1..8f39c3a658f 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -58,6 +58,8 @@ class Group < Namespace add_authentication_token_field :runners_token, encrypted: -> { Feature.enabled?(:groups_tokens_optional_encryption, default_enabled: true) ? :optional : :required } + before_create :default_subgroup_creation_level_to_maintainers + after_create :post_create_hook after_destroy :post_destroy_hook after_save :update_two_factor_requirement @@ -416,10 +418,6 @@ class Group < Namespace super || ::Gitlab::CurrentSettings.default_project_creation end - def subgroup_creation_level - super || ::Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS - end - private def update_two_factor_requirement @@ -449,4 +447,8 @@ class Group < Namespace errors.add(:visibility_level, "#{visibility} is not allowed since there are sub-groups with higher visibility.") end + + def default_subgroup_creation_level_to_maintainers + self.subgroup_creation_level = ::Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS + end end diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 470ce65707d..9ae18d7bab7 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -994,4 +994,12 @@ describe Group do expect(group.project_creation_level).to eq(Gitlab::CurrentSettings.default_project_creation) end end + + describe 'subgroup_creation_level' do + it 'defaults to maintainers' do + group = create (:group) + + expect(group.subgroup_creation_level).to eq(Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS) + end + end end |