Commit 13d9c5dd authored by Fabio Papa's avatar Fabio Papa

Style rules; Revert some examples

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