From 3cccd102ba543e02725d247893729e5c73b38295 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 20 Apr 2022 10:00:54 +0000 Subject: Add latest changes from gitlab-org/gitlab@14-10-stable-ee --- .../api/graphql/mutations/ci/job_retry_spec.rb | 20 +++++++++++++++++--- .../api/graphql/mutations/ci/pipeline_cancel_spec.rb | 1 + 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'spec/requests/api/graphql/mutations/ci') diff --git a/spec/requests/api/graphql/mutations/ci/job_retry_spec.rb b/spec/requests/api/graphql/mutations/ci/job_retry_spec.rb index a14935379dc..ef640183bd8 100644 --- a/spec/requests/api/graphql/mutations/ci/job_retry_spec.rb +++ b/spec/requests/api/graphql/mutations/ci/job_retry_spec.rb @@ -8,7 +8,8 @@ RSpec.describe 'JobRetry' do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project) } let_it_be(:pipeline) { create(:ci_pipeline, project: project, user: user) } - let_it_be(:job) { create(:ci_build, :success, pipeline: pipeline, name: 'build') } + + let(:job) { create(:ci_build, :success, pipeline: pipeline, name: 'build') } let(:mutation) do variables = { @@ -37,10 +38,23 @@ RSpec.describe 'JobRetry' do end it 'retries a job' do - job_id = ::Gitlab::GlobalId.build(job, id: job.id).to_s post_graphql_mutation(mutation, current_user: user) expect(response).to have_gitlab_http_status(:success) - expect(mutation_response['job']['id']).to eq(job_id) + new_job_id = GitlabSchema.object_from_id(mutation_response['job']['id']).sync.id + + new_job = ::Ci::Build.find(new_job_id) + expect(new_job).not_to be_retried + end + + context 'when the job is not retryable' do + let(:job) { create(:ci_build, :retried, pipeline: pipeline) } + + it 'returns an error' do + post_graphql_mutation(mutation, current_user: user) + + expect(mutation_response['job']).to be(nil) + expect(mutation_response['errors']).to match_array(['Job cannot be retried']) + end end end diff --git a/spec/requests/api/graphql/mutations/ci/pipeline_cancel_spec.rb b/spec/requests/api/graphql/mutations/ci/pipeline_cancel_spec.rb index a20ac823550..d9106aa42c4 100644 --- a/spec/requests/api/graphql/mutations/ci/pipeline_cancel_spec.rb +++ b/spec/requests/api/graphql/mutations/ci/pipeline_cancel_spec.rb @@ -47,5 +47,6 @@ RSpec.describe 'PipelineCancel' do expect(response).to have_gitlab_http_status(:success) expect(build.reload).to be_canceled + expect(pipeline.reload).to be_canceled end end -- cgit v1.2.3