diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-29 12:06:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-29 12:06:31 +0300 |
commit | 6b13a226ddfc49140d58e7e88f8703ae0ed90574 (patch) | |
tree | 9a92431e484354f43230fa87adc00a2edbf6f09c /spec/serializers/pipeline_entity_spec.rb | |
parent | 2ac93cb80c4c0a57fde86de8262b569d1e9b9e51 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/serializers/pipeline_entity_spec.rb')
-rw-r--r-- | spec/serializers/pipeline_entity_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/serializers/pipeline_entity_spec.rb b/spec/serializers/pipeline_entity_spec.rb index 02c5b817ea4..d95aaf3d104 100644 --- a/spec/serializers/pipeline_entity_spec.rb +++ b/spec/serializers/pipeline_entity_spec.rb @@ -218,5 +218,28 @@ describe PipelineEntity do expect(subject[:merge_request_event_type]).to be_present end end + + context 'when pipeline has failed builds' do + let_it_be(:pipeline) { create(:ci_pipeline, project: project, user: user) } + let_it_be(:build) { create(:ci_build, :success, pipeline: pipeline) } + let_it_be(:failed_1) { create(:ci_build, :failed, pipeline: pipeline) } + let_it_be(:failed_2) { create(:ci_build, :failed, pipeline: pipeline) } + + context 'when the user can retry the pipeline' do + it 'exposes these failed builds' do + allow(entity).to receive(:can_retry?).and_return(true) + + expect(subject[:failed_builds].map { |b| b[:id] }).to contain_exactly(failed_1.id, failed_2.id) + end + end + + context 'when the user cannot retry the pipeline' do + it 'is nil' do + allow(entity).to receive(:can_retry?).and_return(false) + + expect(subject[:failed_builds]).to be_nil + end + end + end end end |