diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/controllers/admin/runners_controller_spec.rb | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/controllers/admin/runners_controller_spec.rb')
-rw-r--r-- | spec/controllers/admin/runners_controller_spec.rb | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/spec/controllers/admin/runners_controller_spec.rb b/spec/controllers/admin/runners_controller_spec.rb index 8f70cb32d3e..fea59969400 100644 --- a/spec/controllers/admin/runners_controller_spec.rb +++ b/spec/controllers/admin/runners_controller_spec.rb @@ -26,27 +26,12 @@ RSpec.describe Admin::RunnersController do describe '#show' do render_views - let_it_be(:project) { create(:project) } - - before_all do - create(:ci_build, runner: runner, project: project) - end - it 'shows a runner show page' do get :show, params: { id: runner.id } expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template(:show) end - - it 'when runner_read_only_admin_view is off, redirects to the runner edit page' do - stub_feature_flags(runner_read_only_admin_view: false) - - get :show, params: { id: runner.id } - - expect(response).to have_gitlab_http_status(:redirect) - expect(response).to redirect_to edit_admin_runner_path(runner) - end end describe '#edit' do @@ -55,11 +40,6 @@ RSpec.describe Admin::RunnersController do let_it_be(:project) { create(:project) } let_it_be(:project_two) { create(:project) } - before_all do - create(:ci_build, runner: runner, project: project) - create(:ci_build, runner: runner, project: project_two) - end - it 'shows a runner edit page' do get :edit, params: { id: runner.id } @@ -77,9 +57,6 @@ RSpec.describe Admin::RunnersController do control_count = ActiveRecord::QueryRecorder.new { get :edit, params: { id: runner.id } }.count - new_project = create(:project) - create(:ci_build, runner: runner, project: new_project) - # There is one additional query looking up subject.group in ProjectPolicy for the # needs_new_sso_session permission expect { get :edit, params: { id: runner.id } }.not_to exceed_query_limit(control_count + 1) @@ -89,17 +66,42 @@ RSpec.describe Admin::RunnersController do end describe '#update' do - it 'updates the runner and ticks the queue' do - new_desc = runner.description.swapcase + let(:new_desc) { runner.description.swapcase } + let(:runner_params) { { id: runner.id, runner: { description: new_desc } } } - expect do - post :update, params: { id: runner.id, runner: { description: new_desc } } - end.to change { runner.ensure_runner_queue_value } + subject(:request) { post :update, params: runner_params } - runner.reload + context 'with update succeeding' do + before do + expect_next_instance_of(Ci::Runners::UpdateRunnerService, runner) do |service| + expect(service).to receive(:update).with(anything).and_call_original + end + end - expect(response).to have_gitlab_http_status(:found) - expect(runner.description).to eq(new_desc) + it 'updates the runner and ticks the queue' do + expect { request }.to change { runner.ensure_runner_queue_value } + + runner.reload + + expect(response).to have_gitlab_http_status(:found) + expect(runner.description).to eq(new_desc) + end + end + + context 'with update failing' do + before do + expect_next_instance_of(Ci::Runners::UpdateRunnerService, runner) do |service| + expect(service).to receive(:update).with(anything).and_return(false) + end + end + + it 'does not update runner or tick the queue' do + expect { request }.not_to change { runner.ensure_runner_queue_value } + expect { request }.not_to change { runner.reload.description } + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template(:show) + end end end |