gitlab-org--gitlab-foss/spec/controllers/admin/groups_controller_spec.rb
blackst0ne b44a2c801a Update specs to rails5 format
Updates specs to use new rails5 format.

The old format:
`get :show, { some: params }, { some: headers }`

The new format:
`get :show, params: { some: params }, headers: { some: headers }`
2018-12-19 10:04:31 +11:00

64 lines
2 KiB
Ruby

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