diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2019-01-21 17:19:22 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2019-02-04 16:19:53 +0100 |
commit | 814d9c82e32008f51ee0b0e97a52e58335951508 (patch) | |
tree | b43f5197bc6fbd1807b1226bb12b213ecabb77cc /spec/models/ci/build_spec.rb | |
parent | 2b0f4df0217b4a4aee53f964610d66ceedb68dca (diff) | |
download | gitlab-ce-build-annotations.tar.gz |
WIP: Add support for CI build annotationsbuild-annotations
Diffstat (limited to 'spec/models/ci/build_spec.rb')
-rw-r--r-- | spec/models/ci/build_spec.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 8a1bbb26e57..0550b456c21 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -3602,4 +3602,49 @@ describe Ci::Build do end end end + + describe '#first_build_annotation_artifact' do + context 'when there are no build annotations' do + it 'returns nil' do + build = create(:ci_build) + + expect(build.first_build_annotation_artifact).to be_nil + end + end + + context 'when there is one build annotation artifact' do + it 'returns the artifact' do + build = create(:ci_build) + artifact = create( + :ci_job_artifact, + job: build, + file_type: :annotation, + file_format: :gzip + ) + + expect(build.first_build_annotation_artifact).to eq(artifact) + end + end + + context 'when there are multiple build annotation artifacts' do + it 'returns the oldest artifact' do + build = create(:ci_build) + artifact1 = create( + :ci_job_artifact, + job: build, + file_type: :annotation, + file_format: :gzip + ) + + create( + :ci_job_artifact, + job: build, + file_type: :annotation, + file_format: :gzip + ) + + expect(build.first_build_annotation_artifact).to eq(artifact1) + end + end + end end |