Commit d9590c08 authored by Fabio Papa's avatar Fabio Papa Committed by Imre Farkas

Style rules; Revert some examples

parent 5dcae851
......@@ -5,10 +5,13 @@ class AddGroupCreationLevelToNamespaces < ActiveRecord::Migration[5.1]
DOWNTIME = false
disable_ddl_transaction!
def up
unless column_exists?(:namespaces, :subgroup_creation_level)
add_column_with_default(:namespaces, :subgroup_creation_level, :integer, default: 0)
add_column_with_default(:namespaces,
:subgroup_creation_level,
:integer,
default: 0)
end
end
......
......@@ -70,9 +70,14 @@ describe Admin::GroupsController do
end
it 'updates the subgroup_creation_level successfully' do
MAINTAINER = ::Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS
expect do
post :update, params: { id: group.to_param, group: { subgroup_creation_level: ::Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS } }
end.to change { group.reload.subgroup_creation_level }.to(::Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS)
post :update,
params: { id: group.to_param,
group: { subgroup_creation_level: MAINTAINER } }
end.to change { group.reload.subgroup_creation_level }
.to(MAINTAINER)
end
end
end
......@@ -92,7 +92,7 @@ describe 'Edit group settings' do
expect(page).to have_content('Allowed to create subgroups')
end
end
describe 'edit group avatar' do
before do
visit edit_group_path(group)
......
......@@ -76,7 +76,8 @@ describe 'Group show page' do
end
it 'allows creating subgroups' do
expect(page).to have_css("li[data-text='New subgroup']", visible: false)
expect(page)
.to have_css("li[data-text='New subgroup']", visible: false)
end
end
......@@ -87,7 +88,8 @@ describe 'Group show page' do
end
it 'does not allow creating subgroups' do
expect(page).not_to have_selector("li[data-text='New subgroup']", visible: false)
expect(page)
.not_to have_selector("li[data-text='New subgroup']", visible: false)
end
end
end
......@@ -104,8 +106,11 @@ describe 'Group show page' do
end
context 'when subgroup_creation_level is set to maintainer' do
let(:group) { create(:group, subgroup_creation_level: ::Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS) }
let(:group) do
create(:group,
subgroup_creation_level: ::Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS)
end
it 'allows creating subgroups' do
visit path
expect(page).to have_css("li[data-text='New subgroup']", visible: false)
......@@ -113,11 +118,15 @@ describe 'Group show page' do
end
context 'when subgroup_creation_level is set to owners' do
let(:group) { create(:group, subgroup_creation_level: ::Gitlab::Access::OWNER_SUBGROUP_ACCESS) }
let(:group) do
create(:group,
subgroup_creation_level: ::Gitlab::Access::OWNER_SUBGROUP_ACCESS)
end
it 'does not allow creating subgroups' do
visit path
expect(page).not_to have_css("li[data-text='New subgroup']", visible: false)
expect(page)
.not_to have_css("li[data-text='New subgroup']", visible: false)
end
end
end
......@@ -129,7 +138,8 @@ describe 'Group show page' do
end
it 'does not allow creating subgroups' do
expect(page).not_to have_selector("li[data-text='New subgroup']", visible: false)
expect(page)
.not_to have_selector("li[data-text='New subgroup']", visible: false)
end
end
end
......
......@@ -999,7 +999,8 @@ describe Group do
it 'outputs the default one if it is nil' do
group = create(:group, subgroup_creation_level: nil)
expect(group.subgroup_creation_level).to eq(::Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS)
expect(group.subgroup_creation_level)
.to eq(::Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS)
end
end
end
......@@ -145,7 +145,8 @@ describe GroupPolicy do
it 'allows every owner permission except creating subgroups' do
create_subgroup_permission = [:create_subgroup]
updated_owner_permissions = owner_permissions - create_subgroup_permission
updated_owner_permissions =
owner_permissions - create_subgroup_permission
expect_disallowed(*create_subgroup_permission)
expect_allowed(*updated_owner_permissions)
......@@ -157,7 +158,8 @@ describe GroupPolicy do
it 'allows every owner permission except creating subgroups' do
create_subgroup_permission = [:create_subgroup]
updated_owner_permissions = owner_permissions - create_subgroup_permission
updated_owner_permissions =
owner_permissions - create_subgroup_permission
expect_disallowed(*create_subgroup_permission)
expect_allowed(*updated_owner_permissions)
......@@ -169,7 +171,8 @@ describe GroupPolicy do
it 'allows every maintainer permission except creating subgroups' do
create_subgroup_permission = [:create_subgroup]
updated_maintainer_permissions = maintainer_permissions - create_subgroup_permission
updated_maintainer_permissions =
maintainer_permissions - create_subgroup_permission
expect_disallowed(*create_subgroup_permission)
expect_allowed(*updated_maintainer_permissions)
......@@ -475,7 +478,11 @@ describe GroupPolicy do
context "create_subgroup" do
context 'when group has subgroup creation level set to owner' do
let(:group) { create(:group, subgroup_creation_level: ::Gitlab::Access::OWNER_SUBGROUP_ACCESS) }
let(:group) do
create(
:group,
subgroup_creation_level: ::Gitlab::Access::OWNER_SUBGROUP_ACCESS)
end
context 'reporter' do
let(:current_user) { reporter }
......@@ -503,7 +510,11 @@ describe GroupPolicy do
end
context 'when group has subgroup creation level set to maintainer' do
let(:group) { create(:group, subgroup_creation_level: ::Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS) }
let(:group) do
create(
:group,
subgroup_creation_level: ::Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS)
end
context 'reporter' do
let(:current_user) { reporter }
......
......@@ -803,10 +803,10 @@ describe API::Groups do
group2.add_maintainer(user1)
end
it 'can create subgroups' do
it 'cannot create subgroups' do
post api("/groups", user1), params: { parent_id: group2.id, name: 'foo', path: 'foo' }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(403)
end
end
end
......
......@@ -89,9 +89,9 @@ describe Groups::CreateService, '#execute' do
it { is_expected.to be_persisted }
end
context 'as maintainer' do
context 'as Owner' do
before do
group.add_maintainer(user)
group.add_owner(user)
end
it { is_expected.to be_persisted }
......
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