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
|
2021-06-10 03:10:01 +00:00
|
|
|
let_it_be(:group) { create(:group) }
|
|
|
|
let_it_be(:project) { create(:project, namespace: group) }
|
|
|
|
let_it_be(:admin) { create(:admin) }
|
2016-05-29 02:54:17 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2020-11-10 15:09:14 +00:00
|
|
|
describe 'POST #create' do
|
|
|
|
it 'creates group' do
|
|
|
|
expect do
|
|
|
|
post :create, params: { group: { path: 'test', name: 'test' } }
|
|
|
|
end.to change { Group.count }.by(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates namespace_settings for group' do
|
|
|
|
expect do
|
|
|
|
post :create, params: { group: { path: 'test', name: 'test' } }
|
|
|
|
end.to change { NamespaceSetting.count }.by(1)
|
|
|
|
end
|
2021-03-29 18:09:37 +00:00
|
|
|
|
|
|
|
it 'creates admin_note for group' do
|
|
|
|
expect do
|
|
|
|
post :create, params: { group: { path: 'test', name: 'test', admin_note_attributes: { note: 'test' } } }
|
|
|
|
end.to change { Namespace::AdminNote.count }.by(1)
|
|
|
|
end
|
2022-11-04 21:09:59 +00:00
|
|
|
|
|
|
|
it 'delegates to Groups::CreateService service instance' do
|
|
|
|
expect_next_instance_of(::Groups::CreateService) do |service|
|
|
|
|
expect(service).to receive(:execute).once.and_call_original
|
|
|
|
end
|
|
|
|
|
|
|
|
post :create, params: { group: { path: 'test', name: 'test' } }
|
|
|
|
end
|
2020-11-10 15:09:14 +00:00
|
|
|
end
|
2016-05-29 02:54:17 +00:00
|
|
|
end
|