From 51183ad3bdad507325c14c916d70fe3ab9857bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Wed, 1 May 2019 17:31:04 -0400 Subject: [PATCH] Add all reports scope to Ci::JobArtifact --- app/models/ci/job_artifact.rb | 4 ++++ spec/models/ci/job_artifact_spec.rb | 15 +++++++++++++++ 2 files changed, 19 insertions(+) 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 }