summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorFabio Papa <fabtheman@gmail.com>2019-06-28 13:31:47 -0700
committerFabio Papa <fabtheman@gmail.com>2019-07-19 11:55:47 -0700
commit13d9c5dda20095e8f5aaaa173ec2fcc4213ba7bb (patch)
tree631dfbcd99a8b85322043b740fd9b5dde2b5b55c /spec
parentec802d6434230cdbdb487ef6febe6205886035f9 (diff)
downloadgitlab-ce-13d9c5dda20095e8f5aaaa173ec2fcc4213ba7bb.tar.gz
Style rules; Revert some examples
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/admin/groups_controller_spec.rb9
-rw-r--r--spec/features/groups/group_settings_spec.rb2
-rw-r--r--spec/features/groups/show_spec.rb24
-rw-r--r--spec/models/group_spec.rb3
-rw-r--r--spec/policies/group_policy_spec.rb21
-rw-r--r--spec/requests/api/groups_spec.rb4
-rw-r--r--spec/services/groups/create_service_spec.rb4
7 files changed, 47 insertions, 20 deletions
diff --git a/spec/controllers/admin/groups_controller_spec.rb b/spec/controllers/admin/groups_controller_spec.rb
index df11321537f..72f389513f8 100644
--- a/spec/controllers/admin/groups_controller_spec.rb
+++ b/spec/controllers/admin/groups_controller_spec.rb
@@ -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
diff --git a/spec/features/groups/group_settings_spec.rb b/spec/features/groups/group_settings_spec.rb
index 95534d5a2ba..676769c25fe 100644
--- a/spec/features/groups/group_settings_spec.rb
+++ b/spec/features/groups/group_settings_spec.rb
@@ -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)
diff --git a/spec/features/groups/show_spec.rb b/spec/features/groups/show_spec.rb
index 68fa3f4e817..163906010fa 100644
--- a/spec/features/groups/show_spec.rb
+++ b/spec/features/groups/show_spec.rb
@@ -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
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index fd40061dd3a..6627177ad61 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -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
diff --git a/spec/policies/group_policy_spec.rb b/spec/policies/group_policy_spec.rb
index aed9a8e34ff..da186f63eca 100644
--- a/spec/policies/group_policy_spec.rb
+++ b/spec/policies/group_policy_spec.rb
@@ -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 }
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb
index 52d926d5484..c41408fba65 100644
--- a/spec/requests/api/groups_spec.rb
+++ b/spec/requests/api/groups_spec.rb
@@ -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
diff --git a/spec/services/groups/create_service_spec.rb b/spec/services/groups/create_service_spec.rb
index b4e6ddddfac..267ad529d3b 100644
--- a/spec/services/groups/create_service_spec.rb
+++ b/spec/services/groups/create_service_spec.rb
@@ -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 }