Commit ffbab88a authored by Shinya Maeda's avatar Shinya Maeda

Add an integration test to check retried build attributes

This commit adds a integration test to check if a retried job
has the same attributes with the previous job.
parent 1bf3c2b7
...@@ -755,23 +755,52 @@ RSpec.describe Projects::JobsController, :clean_gitlab_redis_shared_state do ...@@ -755,23 +755,52 @@ RSpec.describe Projects::JobsController, :clean_gitlab_redis_shared_state do
before do before do
project.add_developer(user) project.add_developer(user)
sign_in(user) sign_in(user)
post_retry
end end
context 'when job is retryable' do context 'when job is retryable' do
let(:job) { create(:ci_build, :retryable, pipeline: pipeline) } let(:job) { create(:ci_build, :retryable, pipeline: pipeline) }
it 'redirects to the retried job page' do it 'redirects to the retried job page' do
post_retry
expect(response).to have_gitlab_http_status(:found) 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 redirect_to(namespace_project_job_path(id: Ci::Build.last.id))
end end
shared_examples_for 'retried job has the same attributes' do
it 'creates a new build has the same attributes from the previous build' do
expect { post_retry }.to change { Ci::Build.count }.by(1)
retried_build = Ci::Build.last
Ci::RetryBuildService.clone_accessors.each do |accessor|
expect(job.read_attribute(accessor))
.to eq(retried_build.read_attribute(accessor)),
"Mismatched attribute on \"#{accessor}\". " \
"It was \"#{job.read_attribute(accessor)}\" but changed to \"#{retried_build.read_attribute(accessor)}\""
end
end
end
context 'with branch pipeline' do
let!(:job) { create(:ci_build, :retryable, tag: true, when: 'on_success', pipeline: pipeline) }
it_behaves_like 'retried job has the same attributes'
end
context 'with tag pipeline' do
let!(:job) { create(:ci_build, :retryable, tag: false, when: 'on_success', pipeline: pipeline) }
it_behaves_like 'retried job has the same attributes'
end
end end
context 'when job is not retryable' do context 'when job is not retryable' do
let(:job) { create(:ci_build, pipeline: pipeline) } let(:job) { create(:ci_build, pipeline: pipeline) }
it 'renders unprocessable_entity' do it 'renders unprocessable_entity' do
post_retry
expect(response).to have_gitlab_http_status(:unprocessable_entity) expect(response).to have_gitlab_http_status(:unprocessable_entity)
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