2019-04-15 10:17:05 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-05-29 02:54:17 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-04 03:08:05 +00:00
|
|
|
RSpec.describe Admin::GroupsController do
|
2016-05-29 02:54:17 +00:00
|
|
|
let(:group) { create(:group) }
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project, namespace: group) }
|
2016-05-29 02:54:17 +00:00
|
|
|
let(:admin) { create(:admin) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(admin)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'DELETE #destroy' do
|
|
|
|
it 'schedules a group destroy' do
|
2016-08-15 21:26:40 +00:00
|
|
|
Sidekiq::Testing.fake! do
|
2018-12-17 22:52:17 +00:00
|
|
|
expect { delete :destroy, params: { id: project.group.path } }.to change(GroupDestroyWorker.jobs, :size).by(1)
|
2016-08-15 21:26:40 +00:00
|
|
|
end
|
2016-05-29 02:54:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to the admin group path' do
|
2018-12-17 22:52:17 +00:00
|
|
|
delete :destroy, params: { id: project.group.path }
|
2016-05-29 02:54:17 +00:00
|
|
|
|
|
|
|
expect(response).to redirect_to(admin_groups_path)
|
|
|
|
end
|
|
|
|
end
|
2017-04-20 15:20:30 +00:00
|
|
|
|
|
|
|
describe 'PUT #members_update' do
|
|
|
|
let(:group_user) { create(:user) }
|
|
|
|
|
|
|
|
it 'adds user to members' do
|
2018-12-17 22:52:17 +00:00
|
|
|
put :members_update, params: {
|
|
|
|
id: group,
|
|
|
|
user_ids: group_user.id,
|
|
|
|
access_level: Gitlab::Access::GUEST
|
|
|
|
}
|
2017-04-20 15:20:30 +00:00
|
|
|
|
|
|
|
expect(response).to set_flash.to 'Users were successfully added.'
|
|
|
|
expect(response).to redirect_to(admin_group_path(group))
|
|
|
|
expect(group.users).to include group_user
|
|
|
|
end
|
|
|
|
|
2017-06-06 14:55:12 +00:00
|
|
|
it 'can add unlimited members' do
|
2018-12-17 22:52:17 +00:00
|
|
|
put :members_update, params: {
|
|
|
|
id: group,
|
|
|
|
user_ids: 1.upto(1000).to_a.join(','),
|
|
|
|
access_level: Gitlab::Access::GUEST
|
|
|
|
}
|
2017-06-06 14:55:12 +00:00
|
|
|
|
|
|
|
expect(response).to set_flash.to 'Users were successfully added.'
|
|
|
|
expect(response).to redirect_to(admin_group_path(group))
|
|
|
|
end
|
|
|
|
|
2017-04-20 15:20:30 +00:00
|
|
|
it 'adds no user to members' do
|
2018-12-17 22:52:17 +00:00
|
|
|
put :members_update, params: {
|
|
|
|
id: group,
|
|
|
|
user_ids: '',
|
|
|
|
access_level: Gitlab::Access::GUEST
|
|
|
|
}
|
2017-04-20 15:20:30 +00:00
|
|
|
|
|
|
|
expect(response).to set_flash.to 'No users specified.'
|
|
|
|
expect(response).to redirect_to(admin_group_path(group))
|
|
|
|
expect(group.users).not_to include group_user
|
|
|
|
end
|
2019-04-05 18:49:46 +00:00
|
|
|
|
|
|
|
it 'updates the project_creation_level successfully' do
|
|
|
|
expect do
|
|
|
|
post :update, params: { id: group.to_param, group: { project_creation_level: ::Gitlab::Access::NO_ONE_PROJECT_ACCESS } }
|
|
|
|
end.to change { group.reload.project_creation_level }.to(::Gitlab::Access::NO_ONE_PROJECT_ACCESS)
|
|
|
|
end
|
2019-06-26 04:59:10 +00:00
|
|
|
|
|
|
|
it 'updates the subgroup_creation_level successfully' do
|
|
|
|
expect do
|
2019-06-28 20:31:47 +00:00
|
|
|
post :update,
|
|
|
|
params: { id: group.to_param,
|
2019-06-28 20:31:47 +00:00
|
|
|
group: { subgroup_creation_level: ::Gitlab::Access::OWNER_SUBGROUP_ACCESS } }
|
|
|
|
end.to change { group.reload.subgroup_creation_level }.to(::Gitlab::Access::OWNER_SUBGROUP_ACCESS)
|
2019-06-26 04:59:10 +00:00
|
|
|
end
|
2017-04-20 15:20:30 +00:00
|
|
|
end
|
2016-05-29 02:54:17 +00:00
|
|
|
end
|