Add all reports scope to Ci::JobArtifact

This commit is contained in:
Matija Čupić 2019-05-01 17:31:04 -04:00
parent df7bebd67c
commit 51183ad3bd
No known key found for this signature in database
GPG key ID: 4BAF84FFACD2E5DE
2 changed files with 19 additions and 0 deletions

View file

@ -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

View file

@ -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 }