Commit d7be9c37 authored by Matija Čupić's avatar Matija Čupić Committed by Douglas Barbosa Alexandre

Improve background retry tests

parent 03ed05b0
...@@ -853,6 +853,15 @@ RSpec.describe Projects::PipelinesController do ...@@ -853,6 +853,15 @@ RSpec.describe Projects::PipelinesController do
end end
describe 'POST retry.json' do describe 'POST retry.json' do
subject(:post_retry) do
post :retry, params: {
namespace_id: project.namespace,
project_id: project,
id: pipeline.id
},
format: :json
end
let!(:pipeline) { create(:ci_pipeline, :failed, project: project) } let!(:pipeline) { create(:ci_pipeline, :failed, project: project) }
let!(:build) { create(:ci_build, :failed, pipeline: pipeline) } let!(:build) { create(:ci_build, :failed, pipeline: pipeline) }
...@@ -860,24 +869,34 @@ RSpec.describe Projects::PipelinesController do ...@@ -860,24 +869,34 @@ RSpec.describe Projects::PipelinesController do
before do before do
stub_const('::Ci::RetryPipelineWorker', worker_spy) stub_const('::Ci::RetryPipelineWorker', worker_spy)
post :retry, params: {
namespace_id: project.namespace,
project_id: project,
id: pipeline.id
},
format: :json
end end
it 'retries a pipeline in the background without returning any content' do it 'retries a pipeline in the background without returning any content' do
post_retry
expect(response).to have_gitlab_http_status(:no_content) expect(response).to have_gitlab_http_status(:no_content)
expect(::Ci::RetryPipelineWorker).to have_received(:perform_async).with(pipeline.id, user.id) expect(::Ci::RetryPipelineWorker).to have_received(:perform_async).with(pipeline.id, user.id)
end end
context 'when feature flag is disabled' do
before do
stub_feature_flags(background_pipeline_retry_endpoint: false)
end
it 'retries the pipeline without returning any content' do
post_retry
expect(response).to have_gitlab_http_status(:no_content)
expect(build.reload).to be_retried
end
end
context 'when builds are disabled' do context 'when builds are disabled' do
let(:feature) { ProjectFeature::DISABLED } let(:feature) { ProjectFeature::DISABLED }
it 'fails to retry pipeline' do it 'fails to retry pipeline' do
post_retry
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
......
...@@ -43,8 +43,8 @@ RSpec.describe Ci::RetryPipelineWorker do ...@@ -43,8 +43,8 @@ RSpec.describe Ci::RetryPipelineWorker do
let(:pipeline_id) { 1234 } let(:pipeline_id) { 1234 }
let(:user_id) { 1234 } let(:user_id) { 1234 }
it 'returns false' do it 'returns nil' do
expect(perform).to eq(nil) expect(perform).to be_nil
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment