summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/ci/build.rb4
-rw-r--r--app/serializers/build_details_entity.rb7
-rw-r--r--spec/models/ci/build_spec.rb12
-rw-r--r--spec/serializers/build_details_entity_spec.rb3
4 files changed, 22 insertions, 4 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 1b67a7272bc..56786fae6ea 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -765,6 +765,10 @@ module Ci
end
end
+ def report_artifacts
+ job_artifacts.with_reports
+ end
+
# Virtual deployment status depending on the environment status.
def deployment_status
return unless starts_environment?
diff --git a/app/serializers/build_details_entity.rb b/app/serializers/build_details_entity.rb
index 6be0a8d1499..67e44ee9d10 100644
--- a/app/serializers/build_details_entity.rb
+++ b/app/serializers/build_details_entity.rb
@@ -42,9 +42,10 @@ class BuildDetailsEntity < JobEntity
end
end
- expose :reports, if: -> (*) { can?(current_user, :read_build, build) }, using: JobArtifactReportEntity do |build|
- build.job_artifacts.with_reports
- end
+ expose :report_artifacts,
+ as: :reports,
+ using: JobArtifactReportEntity,
+ if: -> (*) { can?(current_user, :read_build, build) }
expose :erased_by, if: -> (*) { build.erased? }, using: UserEntity
expose :erase_path, if: -> (*) { build.erasable? && can?(current_user, :erase_build, build) } do |build|
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index bc81c34f7ab..32eef9e0e01 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -3490,6 +3490,18 @@ describe Ci::Build do
end
end
+ describe '#report_artifacts' do
+ subject { build.report_artifacts }
+
+ context 'when the build has reports' do
+ let!(:report) { create(:ci_job_artifact, :codequality, job: build) }
+
+ it 'returns the artifacts with reports' do
+ expect(subject).to contain_exactly(report)
+ end
+ end
+ end
+
describe '#artifacts_metadata_entry' do
set(:build) { create(:ci_build, project: project) }
let(:path) { 'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif' }
diff --git a/spec/serializers/build_details_entity_spec.rb b/spec/serializers/build_details_entity_spec.rb
index 0b8ed873bde..d922e8246c7 100644
--- a/spec/serializers/build_details_entity_spec.rb
+++ b/spec/serializers/build_details_entity_spec.rb
@@ -151,7 +151,8 @@ describe BuildDetailsEntity do
let!(:report) { create(:ci_job_artifact, :codequality, job: build) }
it 'exposes the report artifacts' do
- expect(subject[:reports]).not_to be_empty
+ expect(subject[:reports].count).to eq(1)
+ expect(subject[:reports].first[:file_type]).to eq('codequality')
end
end
end