2016-09-13 17:45:13 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Admin::GroupsController do
|
|
|
|
let(:group) { create(:group) }
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:project) { create(:project, namespace: group) }
|
2016-09-13 17:45:13 +05:30
|
|
|
let(:admin) { create(:admin) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(admin)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'DELETE #destroy' do
|
|
|
|
it 'schedules a group destroy' do
|
|
|
|
Sidekiq::Testing.fake! do
|
2019-02-13 22:33:31 +05:30
|
|
|
expect { delete :destroy, params: { id: project.group.path } }.to change(GroupDestroyWorker.jobs, :size).by(1)
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to the admin group path' do
|
2019-02-13 22:33:31 +05:30
|
|
|
delete :destroy, params: { id: project.group.path }
|
2016-09-13 17:45:13 +05:30
|
|
|
|
|
|
|
expect(response).to redirect_to(admin_groups_path)
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
describe 'PUT #members_update' do
|
|
|
|
let(:group_user) { create(:user) }
|
|
|
|
|
|
|
|
it 'adds user to members' do
|
2019-02-13 22:33:31 +05:30
|
|
|
put :members_update, params: {
|
|
|
|
id: group,
|
|
|
|
user_ids: group_user.id,
|
|
|
|
access_level: Gitlab::Access::GUEST
|
|
|
|
}
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
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-09-10 17:25:29 +05:30
|
|
|
it 'can add unlimited members' do
|
2019-02-13 22:33:31 +05:30
|
|
|
put :members_update, params: {
|
|
|
|
id: group,
|
|
|
|
user_ids: 1.upto(1000).to_a.join(','),
|
|
|
|
access_level: Gitlab::Access::GUEST
|
|
|
|
}
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
expect(response).to set_flash.to 'Users were successfully added.'
|
|
|
|
expect(response).to redirect_to(admin_group_path(group))
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
it 'adds no user to members' do
|
2019-02-13 22:33:31 +05:30
|
|
|
put :members_update, params: {
|
|
|
|
id: group,
|
|
|
|
user_ids: '',
|
|
|
|
access_level: Gitlab::Access::GUEST
|
|
|
|
}
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
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
|
|
|
|
end
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|