Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/groups/runners_controller_spec.rb')
-rw-r--r--spec/controllers/groups/runners_controller_spec.rb201
1 files changed, 0 insertions, 201 deletions
diff --git a/spec/controllers/groups/runners_controller_spec.rb b/spec/controllers/groups/runners_controller_spec.rb
index a53f09e2afc..77c62c0d930 100644
--- a/spec/controllers/groups/runners_controller_spec.rb
+++ b/spec/controllers/groups/runners_controller_spec.rb
@@ -194,205 +194,4 @@ RSpec.describe Groups::RunnersController do
end
end
end
-
- describe '#destroy' do
- context 'when user is an owner' do
- before do
- group.add_owner(user)
- end
-
- it 'destroys the runner and redirects' do
- expect_next_instance_of(Ci::Runners::UnregisterRunnerService, runner, user) do |service|
- expect(service).to receive(:execute).once.and_call_original
- end
-
- delete :destroy, params: params
-
- expect(response).to have_gitlab_http_status(:found)
- expect(Ci::Runner.find_by(id: runner.id)).to be_nil
- end
-
- it 'destroys the project runner and redirects' do
- delete :destroy, params: params_runner_project
-
- expect(response).to have_gitlab_http_status(:found)
- expect(Ci::Runner.find_by(id: runner_project.id)).to be_nil
- end
- end
-
- context 'with runner associated with multiple projects' do
- let_it_be(:project_2) { create(:project, group: group) }
-
- let(:runner_project_2) { create(:ci_runner, :project, projects: [project, project_2]) }
- let(:params_runner_project_2) { { group_id: group, id: runner_project_2 } }
-
- context 'when user is an admin', :enable_admin_mode do
- let(:user) { create(:user, :admin) }
-
- before do
- sign_in(user)
- end
-
- it 'destroys the project runner and redirects' do
- delete :destroy, params: params_runner_project_2
-
- expect(response).to have_gitlab_http_status(:found)
- expect(Ci::Runner.find_by(id: runner_project_2.id)).to be_nil
- end
- end
-
- context 'when user is an owner' do
- before do
- group.add_owner(user)
- end
-
- it 'does not destroy the project runner' do
- delete :destroy, params: params_runner_project_2
-
- expect(response).to have_gitlab_http_status(:found)
- expect(flash[:alert]).to eq('Runner cannot be deleted, please contact your administrator.')
- expect(Ci::Runner.find_by(id: runner_project_2.id)).to be_present
- end
- end
- end
-
- context 'when user is not an owner' do
- before do
- group.add_maintainer(user)
- end
-
- it 'responds 404 and does not destroy the runner' do
- delete :destroy, params: params
-
- expect(response).to have_gitlab_http_status(:not_found)
- expect(Ci::Runner.find_by(id: runner.id)).to be_present
- end
-
- it 'responds 404 and does not destroy the project runner' do
- delete :destroy, params: params_runner_project
-
- expect(response).to have_gitlab_http_status(:not_found)
- expect(Ci::Runner.find_by(id: runner_project.id)).to be_present
- end
- end
- end
-
- describe '#resume' do
- context 'when user is an owner' do
- before do
- group.add_owner(user)
- end
-
- it 'marks the runner as active, ticks the queue, and redirects' do
- runner.update!(active: false)
-
- expect do
- post :resume, params: params
- end.to change { runner.ensure_runner_queue_value }
-
- expect(response).to have_gitlab_http_status(:found)
- expect(runner.reload.active).to eq(true)
- end
-
- it 'marks the project runner as active, ticks the queue, and redirects' do
- runner_project.update!(active: false)
-
- expect do
- post :resume, params: params_runner_project
- end.to change { runner_project.ensure_runner_queue_value }
-
- expect(response).to have_gitlab_http_status(:found)
- expect(runner_project.reload.active).to eq(true)
- end
- end
-
- context 'when user is not an owner' do
- before do
- group.add_maintainer(user)
- end
-
- it 'responds 404 and does not activate the runner' do
- runner.update!(active: false)
-
- expect do
- post :resume, params: params
- end.not_to change { runner.ensure_runner_queue_value }
-
- expect(response).to have_gitlab_http_status(:not_found)
- expect(runner.reload.active).to eq(false)
- end
-
- it 'responds 404 and does not activate the project runner' do
- runner_project.update!(active: false)
-
- expect do
- post :resume, params: params_runner_project
- end.not_to change { runner_project.ensure_runner_queue_value }
-
- expect(response).to have_gitlab_http_status(:not_found)
- expect(runner_project.reload.active).to eq(false)
- end
- end
- end
-
- describe '#pause' do
- context 'when user is an owner' do
- before do
- group.add_owner(user)
- end
-
- it 'marks the runner as inactive, ticks the queue, and redirects' do
- runner.update!(active: true)
-
- expect do
- post :pause, params: params
- end.to change { runner.ensure_runner_queue_value }
-
- expect(response).to have_gitlab_http_status(:found)
- expect(runner.reload.active).to eq(false)
- end
-
- it 'marks the project runner as inactive, ticks the queue, and redirects' do
- runner_project.update!(active: true)
-
- expect do
- post :pause, params: params_runner_project
- end.to change { runner_project.ensure_runner_queue_value }
-
- expect(response).to have_gitlab_http_status(:found)
- expect(runner_project.reload.active).to eq(false)
- end
- end
-
- context 'when user is not an owner' do
- before do
- # Disable limit checking
- allow(runner).to receive(:runner_scope).and_return(nil)
-
- group.add_maintainer(user)
- end
-
- it 'responds 404 and does not update the runner or queue' do
- runner.update!(active: true)
-
- expect do
- post :pause, params: params
- end.not_to change { runner.ensure_runner_queue_value }
-
- expect(response).to have_gitlab_http_status(:not_found)
- expect(runner.reload.active).to eq(true)
- end
-
- it 'responds 404 and does not update the project runner or queue' do
- runner_project.update!(active: true)
-
- expect do
- post :pause, params: params
- end.not_to change { runner_project.ensure_runner_queue_value }
-
- expect(response).to have_gitlab_http_status(:not_found)
- expect(runner_project.reload.active).to eq(true)
- end
- end
- end
end