Commit e962ffbc authored by Fabio Papa's avatar Fabio Papa

Make maintainers the default setting for creating subgroups

parent d32ed929
...@@ -58,6 +58,8 @@ class Group < Namespace ...@@ -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 } 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_create :post_create_hook
after_destroy :post_destroy_hook after_destroy :post_destroy_hook
after_save :update_two_factor_requirement after_save :update_two_factor_requirement
...@@ -416,10 +418,6 @@ class Group < Namespace ...@@ -416,10 +418,6 @@ class Group < Namespace
super || ::Gitlab::CurrentSettings.default_project_creation super || ::Gitlab::CurrentSettings.default_project_creation
end end
def subgroup_creation_level
super || ::Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS
end
private private
def update_two_factor_requirement def update_two_factor_requirement
...@@ -449,4 +447,8 @@ class Group < Namespace ...@@ -449,4 +447,8 @@ class Group < Namespace
errors.add(:visibility_level, "#{visibility} is not allowed since there are sub-groups with higher visibility.") errors.add(:visibility_level, "#{visibility} is not allowed since there are sub-groups with higher visibility.")
end end
def default_subgroup_creation_level_to_maintainers
self.subgroup_creation_level = ::Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS
end
end end
...@@ -994,4 +994,12 @@ describe Group do ...@@ -994,4 +994,12 @@ describe Group do
expect(group.project_creation_level).to eq(Gitlab::CurrentSettings.default_project_creation) expect(group.project_creation_level).to eq(Gitlab::CurrentSettings.default_project_creation)
end end
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 end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment