Commit e4fc7ca9 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '211887-dedup-groups-controller-specs' into 'master'

De-duplicate groups_controller spec

See merge request gitlab-org/gitlab!27874
parents 855dbfcb 71c7b9be
......@@ -202,7 +202,6 @@ GitlabSecurity/PublicSend:
Gitlab/DuplicateSpecLocation:
Exclude:
- ee/spec/controllers/groups_controller_spec.rb
- ee/spec/controllers/projects/jobs_controller_spec.rb
- ee/spec/helpers/auth_helper_spec.rb
- ee/spec/lib/gitlab/gl_repository_spec.rb
......@@ -215,7 +214,6 @@ Gitlab/DuplicateSpecLocation:
- ee/spec/services/merge_requests/refresh_service_spec.rb
- ee/spec/services/merge_requests/update_service_spec.rb
- ee/spec/services/system_hooks_service_spec.rb
- ee/spec/controllers/ee/groups_controller_spec.rb
- ee/spec/controllers/ee/projects/jobs_controller_spec.rb
- ee/spec/helpers/ee/auth_helper_spec.rb
- ee/spec/lib/ee/gitlab/gl_repository_spec.rb
......
......@@ -234,4 +234,56 @@ describe GroupsController do
end
end
end
describe 'POST #create' do
context 'authorization' do
it 'allows an auditor with "can_create_group" set to true to create a group' do
sign_in(create(:user, :auditor, can_create_group: true))
expect do
post :create, params: { group: { name: 'new_group', path: "new_group" } }
end.to change { Group.count }.by(1)
expect(response).to have_gitlab_http_status(:found)
end
end
end
describe 'PUT #update' do
let(:group) { create(:group) }
context 'when max_pages_size param is specified' do
let(:params) { { max_pages_size: 100 } }
let(:request) do
post :update, params: { id: group.to_param, group: params }
end
let(:user) { create(:user) }
before do
stub_licensed_features(pages_size_limit: true)
group.add_owner(user)
sign_in(user)
end
context 'when user is an admin' do
let(:user) { create(:admin) }
it 'updates max_pages_size' do
request
expect(group.reload.max_pages_size).to eq(100)
end
end
context 'when user is not an admin' do
it 'does not update max_pages_size' do
request
expect(group.reload.max_pages_size).to eq(nil)
end
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe GroupsController do
include ExternalAuthorizationServiceHelpers
let(:user) { create(:user) }
describe 'POST #create' do
context 'authorization' do
it 'allows an auditor with "can_create_group" set to true to create a group' do
sign_in(create(:user, :auditor, can_create_group: true))
expect do
post :create, params: { group: { name: 'new_group', path: "new_group" } }
end.to change { Group.count }.by(1)
expect(response).to have_gitlab_http_status(:found)
end
end
end
describe 'PUT #update' do
let(:group) { create(:group) }
context 'when max_pages_size param is specified' do
let(:params) { { max_pages_size: 100 } }
let(:request) do
post :update, params: { id: group.to_param, group: params }
end
let(:user) { create(:user) }
before do
stub_licensed_features(pages_size_limit: true)
group.add_owner(user)
sign_in(user)
end
context 'when user is an admin' do
let(:user) { create(:admin) }
it 'updates max_pages_size' do
request
expect(group.reload.max_pages_size).to eq(100)
end
end
context 'when user is not an admin' do
it 'does not update max_pages_size' do
request
expect(group.reload.max_pages_size).to eq(nil)
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