diff options
Diffstat (limited to 'spec/controllers/projects/jobs_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/jobs_controller_spec.rb | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb index 3dc89365530..8fb9623c21a 100644 --- a/spec/controllers/projects/jobs_controller_spec.rb +++ b/spec/controllers/projects/jobs_controller_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'spec_helper' -RSpec.describe Projects::JobsController, :clean_gitlab_redis_shared_state do +RSpec.describe Projects::JobsController, :clean_gitlab_redis_shared_state, feature_category: :continuous_integration do include ApiHelpers include HttpIOHelpers @@ -809,14 +809,48 @@ RSpec.describe Projects::JobsController, :clean_gitlab_redis_shared_state do sign_in(user) end + context 'when job is not retryable' do + context 'and the job is a bridge' do + let(:job) { create(:ci_bridge, :failed, :reached_max_descendant_pipelines_depth, pipeline: pipeline) } + + it 'renders unprocessable_entity' do + post_retry + + expect(response).to have_gitlab_http_status(:unprocessable_entity) + end + end + + context 'and the job is a build' do + let(:job) { create(:ci_build, :deployment_rejected, pipeline: pipeline) } + + it 'renders unprocessable_entity' do + post_retry + + expect(response).to have_gitlab_http_status(:unprocessable_entity) + end + end + end + context 'when job is retryable' do - let(:job) { create(:ci_build, :retryable, pipeline: pipeline) } + context 'and the job is a bridge' do + let(:job) { create(:ci_bridge, :retryable, pipeline: pipeline) } - it 'redirects to the retried job page' do - post_retry + it 'responds :ok' do + post_retry - expect(response).to have_gitlab_http_status(:found) - expect(response).to redirect_to(namespace_project_job_path(id: Ci::Build.last.id)) + expect(response).to have_gitlab_http_status(:ok) + end + end + + context 'and the job is a build' do + let(:job) { create(:ci_build, :retryable, pipeline: pipeline) } + + it 'redirects to the retried job page' do + post_retry + + expect(response).to have_gitlab_http_status(:found) + expect(response).to redirect_to(namespace_project_job_path(id: Ci::Build.last.id)) + end end shared_examples_for 'retried job has the same attributes' do @@ -847,16 +881,6 @@ RSpec.describe Projects::JobsController, :clean_gitlab_redis_shared_state do end end - context 'when job is not retryable' do - let(:job) { create(:ci_build, pipeline: pipeline) } - - it 'renders unprocessable_entity' do - post_retry - - expect(response).to have_gitlab_http_status(:unprocessable_entity) - end - end - def post_retry post :retry, params: { namespace_id: project.namespace, |