Commit d4c53e17 authored by Fabio Papa's avatar Fabio Papa

Apply changes recomended by merge request coach

parent b36d78ea
...@@ -416,6 +416,10 @@ class Group < Namespace ...@@ -416,6 +416,10 @@ 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
......
...@@ -16,6 +16,12 @@ ...@@ -16,6 +16,12 @@
.col-sm-10 .col-sm-10
= f.select :project_creation_level, options_for_select(::Gitlab::Access.project_creation_options, @group.project_creation_level), {}, class: 'form-control' = f.select :project_creation_level, options_for_select(::Gitlab::Access.project_creation_options, @group.project_creation_level), {}, class: 'form-control'
.form-group.row
.col-sm-2.col-form-label
= f.label s_('SubgroupCreationlevel|Allowed to create subgroups')
.col-sm-10
= f.select :subgroup_creation_level, options_for_select(::Gitlab::Access.subgroup_creation_options, @group.subgroup_creation_level), {}, class: 'form-control'
.form-group.row .form-group.row
.col-sm-2.col-form-label.pt-0 .col-sm-2.col-form-label.pt-0
= f.label :require_two_factor_authentication, 'Two-factor authentication' = f.label :require_two_factor_authentication, 'Two-factor authentication'
......
...@@ -7,18 +7,13 @@ class AddGroupCreationLevelToNamespaces < ActiveRecord::Migration[5.1] ...@@ -7,18 +7,13 @@ class AddGroupCreationLevelToNamespaces < ActiveRecord::Migration[5.1]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
unless column_exists?(:namespaces, :subgroup_creation_level) add_column(:namespaces, :subgroup_creation_level, :integer)
add_column_with_default(:namespaces, change_column_default(:namespaces,
:subgroup_creation_level, :subgroup_creation_level,
:integer, ::Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS)
default: 0)
change_column_default(:namespaces, :subgroup_creation_level, 1)
end
end end
def down def down
if column_exists?(:namespaces, :subgroup_creation_level)
remove_column(:namespaces, :subgroup_creation_level) remove_column(:namespaces, :subgroup_creation_level)
end end
end
end end
...@@ -2119,7 +2119,7 @@ ActiveRecord::Schema.define(version: 2019_07_15_114644) do ...@@ -2119,7 +2119,7 @@ ActiveRecord::Schema.define(version: 2019_07_15_114644) do
t.string "ldap_sync_status", default: "ready", null: false t.string "ldap_sync_status", default: "ready", null: false
t.boolean "membership_lock", default: false t.boolean "membership_lock", default: false
t.integer "last_ci_minutes_usage_notification_level" t.integer "last_ci_minutes_usage_notification_level"
t.integer "subgroup_creation_level", default: 0, null: false t.integer "subgroup_creation_level", default: 1
t.index ["created_at"], name: "index_namespaces_on_created_at", using: :btree t.index ["created_at"], name: "index_namespaces_on_created_at", using: :btree
t.index ["custom_project_templates_group_id", "type"], name: "index_namespaces_on_custom_project_templates_group_id_and_type", where: "(custom_project_templates_group_id IS NOT NULL)", using: :btree t.index ["custom_project_templates_group_id", "type"], name: "index_namespaces_on_custom_project_templates_group_id_and_type", where: "(custom_project_templates_group_id IS NOT NULL)", using: :btree
t.index ["file_template_project_id"], name: "index_namespaces_on_file_template_project_id", using: :btree t.index ["file_template_project_id"], name: "index_namespaces_on_file_template_project_id", using: :btree
......
...@@ -70,13 +70,11 @@ describe Admin::GroupsController do ...@@ -70,13 +70,11 @@ describe Admin::GroupsController do
end end
it 'updates the subgroup_creation_level successfully' do it 'updates the subgroup_creation_level successfully' do
OWNER = ::Gitlab::Access::OWNER_SUBGROUP_ACCESS
expect do expect do
post :update, post :update,
params: { id: group.to_param, params: { id: group.to_param,
group: { subgroup_creation_level: OWNER } } group: { subgroup_creation_level: ::Gitlab::Access::OWNER_SUBGROUP_ACCESS } }
end.to change { group.reload.subgroup_creation_level }.to(OWNER) end.to change { group.reload.subgroup_creation_level }.to(::Gitlab::Access::OWNER_SUBGROUP_ACCESS)
end end
end end
end end
...@@ -102,6 +102,15 @@ describe 'Admin Groups' do ...@@ -102,6 +102,15 @@ describe 'Admin Groups' do
expect_selected_visibility(group.visibility_level) expect_selected_visibility(group.visibility_level)
end end
it 'shows the subgroup creation level dropdown populated with the group subgroup_creation_level value' do
group = create(:group, :private, :owner_subgroup_creation_only)
visit admin_group_edit_path(group)
expect(page).to have_select("group_subgroup_creation_level",
selected: ::Gitlab::Access.subgroup_creation_options.keys[group.subgroup_creation_level])
end
it 'edit group path does not change group name', :js do it 'edit group path does not change group name', :js do
group = create(:group, :private) group = create(:group, :private)
......
...@@ -71,7 +71,7 @@ describe 'Group show page' do ...@@ -71,7 +71,7 @@ describe 'Group show page' do
sign_in(owner) sign_in(owner)
end end
context 'when subgroups are supported', :js, :nested_groups do context 'when subgroups are supported', :nested_groups do
before do before do
allow(Group).to receive(:supports_nested_objects?) { true } allow(Group).to receive(:supports_nested_objects?) { true }
visit path visit path
...@@ -101,7 +101,7 @@ describe 'Group show page' do ...@@ -101,7 +101,7 @@ describe 'Group show page' do
sign_in(maintainer) sign_in(maintainer)
end end
context 'when subgroups are supported', :js, :nested_groups do context 'when subgroups are supported', :nested_groups do
before do before do
allow(Group).to receive(:supports_nested_objects?) { true } allow(Group).to receive(:supports_nested_objects?) { true }
end end
......
# coding: utf-8
# frozen_string_literal: true # frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
...@@ -88,14 +87,6 @@ describe Groups::CreateService, '#execute' do ...@@ -88,14 +87,6 @@ describe Groups::CreateService, '#execute' do
it { is_expected.to be_persisted } it { is_expected.to be_persisted }
end end
context 'as maintainer' do
before do
group.add_maintainer(user)
end
it { is_expected.to be_persisted }
end
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