Commit c86fa0e4 authored by Matija Čupić's avatar Matija Čupić

Rename with_all_reports to with_reports

parent 9e6f3774
...@@ -26,10 +26,13 @@ module Ci ...@@ -26,10 +26,13 @@ module Ci
metrics: 'metrics.txt' metrics: 'metrics.txt'
}.freeze }.freeze
TYPE_AND_FORMAT_PAIRS = { INTERNAL_TYPES = {
archive: :zip, archive: :zip,
metadata: :gzip, metadata: :gzip,
trace: :raw, trace: :raw
}.freeze
REPORT_TYPES = {
junit: :gzip, junit: :gzip,
metrics: :gzip, metrics: :gzip,
...@@ -45,6 +48,8 @@ module Ci ...@@ -45,6 +48,8 @@ module Ci
performance: :raw performance: :raw
}.freeze }.freeze
TYPE_AND_FORMAT_PAIRS = INTERNAL_TYPES.merge(REPORT_TYPES).freeze
belongs_to :project belongs_to :project
belongs_to :job, class_name: "Ci::Build", foreign_key: :job_id belongs_to :job, class_name: "Ci::Build", foreign_key: :job_id
...@@ -66,8 +71,8 @@ module Ci ...@@ -66,8 +71,8 @@ module Ci
where(file_type: types) where(file_type: types)
end end
scope :with_all_reports, -> do scope :with_reports, -> do
where(file_type: self.file_types.values.drop(3)) with_file_types(REPORT_TYPES.keys.map(&:to_s))
end end
scope :test_reports, -> do scope :test_reports, -> do
......
...@@ -43,7 +43,7 @@ class BuildDetailsEntity < JobEntity ...@@ -43,7 +43,7 @@ class BuildDetailsEntity < JobEntity
end end
expose :reports, if: -> (*) { can?(current_user, :read_build, build) }, using: JobArtifactReportEntity do |build| expose :reports, if: -> (*) { can?(current_user, :read_build, build) }, using: JobArtifactReportEntity do |build|
build.job_artifacts.merge(Ci::JobArtifact.with_all_reports) build.job_artifacts.with_reports
end end
expose :erased_by, if: -> (*) { build.erased? }, using: UserEntity expose :erased_by, if: -> (*) { build.erased? }, using: UserEntity
......
...@@ -8,8 +8,6 @@ class JobArtifactReportEntity < Grape::Entity ...@@ -8,8 +8,6 @@ class JobArtifactReportEntity < Grape::Entity
expose :size expose :size
expose :download_path do |artifact| expose :download_path do |artifact|
download_project_job_artifacts_path(job.project, job, file_type: artifact.file_format) download_project_job_artifacts_path(artifact.job.project, artifact.job, file_type: artifact.file_format)
end end
alias_method :job, :object
end end
...@@ -23,10 +23,10 @@ describe Ci::JobArtifact do ...@@ -23,10 +23,10 @@ describe Ci::JobArtifact do
it_behaves_like 'having unique enum values' it_behaves_like 'having unique enum values'
describe '.with_all_reports' do describe '.with_reports' do
let!(:artifact) { create(:ci_job_artifact, :archive) } let!(:artifact) { create(:ci_job_artifact, :archive) }
subject { described_class.with_all_reports } subject { described_class.with_reports }
it { is_expected.to be_empty } it { is_expected.to be_empty }
......
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