Add test for cloning attributes when retrying a build
This commit is contained in:
parent
7e8a3f7ef7
commit
658c5f32a3
|
@ -10,6 +10,34 @@ describe Ci::RetryBuildService, :services do
|
|||
described_class.new(project, user)
|
||||
end
|
||||
|
||||
shared_examples 'build duplication' do
|
||||
let(:build) do
|
||||
create(:ci_build, :failed, :artifacts,
|
||||
pipeline: pipeline,
|
||||
coverage: 90.0,
|
||||
coverage_regex: '/(d+)/')
|
||||
end
|
||||
|
||||
it 'clones expected attributes' do
|
||||
clone_attributes = %w[ref tag project pipeline options commands tag_list
|
||||
name allow_failure stage stage_idx trigger_request
|
||||
yaml_variables when environment coverage_regex]
|
||||
|
||||
clone_attributes.each do |attribute|
|
||||
expect(new_build.send(attribute)).to eq build.send(attribute)
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not clone forbidden attributes' do
|
||||
forbidden_attributes = %w[id status token user artifacts_file
|
||||
artifacts_metadata coverage]
|
||||
|
||||
forbidden_attributes.each do |attribute|
|
||||
expect(new_build.send(attribute)).not_to eq build.send(attribute)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#execute' do
|
||||
let(:new_build) { service.execute(build) }
|
||||
|
||||
|
@ -18,6 +46,8 @@ describe Ci::RetryBuildService, :services do
|
|||
project.add_developer(user)
|
||||
end
|
||||
|
||||
it_behaves_like 'build duplication'
|
||||
|
||||
it 'creates a new build that represents the old one' do
|
||||
expect(new_build.name).to eq build.name
|
||||
end
|
||||
|
@ -62,6 +92,8 @@ describe Ci::RetryBuildService, :services do
|
|||
project.add_developer(user)
|
||||
end
|
||||
|
||||
it_behaves_like 'build duplication'
|
||||
|
||||
it 'creates a new build that represents the old one' do
|
||||
expect(new_build.name).to eq build.name
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue