summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2019-05-01 17:31:04 -0400
committerMatija Čupić <matteeyah@gmail.com>2019-05-28 17:04:57 +0200
commit51183ad3bdad507325c14c916d70fe3ab9857bfc (patch)
tree294e5bb97dbe40a3b3fe9ed6c8ca3b015bfa496d
parentdf7bebd67c6307d16b2ac495e7cd09f55b39ba16 (diff)
downloadgitlab-ce-51183ad3bdad507325c14c916d70fe3ab9857bfc.tar.gz
Add all reports scope to Ci::JobArtifact
-rw-r--r--app/models/ci/job_artifact.rb4
-rw-r--r--spec/models/ci/job_artifact_spec.rb15
2 files changed, 19 insertions, 0 deletions
diff --git a/app/models/ci/job_artifact.rb b/app/models/ci/job_artifact.rb
index 3beb76ffc2b..16fa77e0048 100644
--- a/app/models/ci/job_artifact.rb
+++ b/app/models/ci/job_artifact.rb
@@ -66,6 +66,10 @@ module Ci
where(file_type: types)
end
+ scope :with_all_reports, -> do
+ where(file_type: self.file_types.values.drop(3))
+ end
+
scope :test_reports, -> do
with_file_types(TEST_REPORT_FILE_TYPES)
end
diff --git a/spec/models/ci/job_artifact_spec.rb b/spec/models/ci/job_artifact_spec.rb
index 5964f66c398..d3809f0a460 100644
--- a/spec/models/ci/job_artifact_spec.rb
+++ b/spec/models/ci/job_artifact_spec.rb
@@ -23,6 +23,21 @@ describe Ci::JobArtifact do
it_behaves_like 'having unique enum values'
+ describe '.with_all_reports' do
+ let!(:artifact) { create(:ci_job_artifact, :archive) }
+
+ subject { described_class.with_all_reports }
+
+ it { is_expected.to be_empty }
+
+ context 'when there are reports' do
+ let!(:metrics_report) { create(:ci_job_artifact, :junit) }
+ let!(:codequality_report) { create(:ci_job_artifact, :codequality) }
+
+ it { is_expected.to eq([metrics_report, codequality_report]) }
+ end
+ end
+
describe '.test_reports' do
subject { described_class.test_reports }