summaryrefslogtreecommitdiff
path: root/spec/models/ci/pipeline_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-11 09:08:39 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-11 09:08:39 +0000
commit1078b7bf25c2cb6e03c57da9ae25b0512858556f (patch)
treea50fbfaddb22aca89055296c4c532c7ecb2b1ca0 /spec/models/ci/pipeline_spec.rb
parent55733b19c526145cceb120e8bb874d476a84383a (diff)
downloadgitlab-ce-1078b7bf25c2cb6e03c57da9ae25b0512858556f.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/ci/pipeline_spec.rb')
-rw-r--r--spec/models/ci/pipeline_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index 18f3c4af08c..6efec87464b 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -2678,6 +2678,40 @@ describe Ci::Pipeline, :mailer do
end
end
+ describe '#test_reports_count', :use_clean_rails_memory_store_caching do
+ subject { pipeline.test_reports }
+
+ context 'when pipeline has multiple builds with test reports' do
+ let!(:build_rspec) { create(:ci_build, :success, name: 'rspec', pipeline: pipeline, project: project) }
+ let!(:build_java) { create(:ci_build, :success, name: 'java', pipeline: pipeline, project: project) }
+
+ before do
+ create(:ci_job_artifact, :junit, job: build_rspec, project: project)
+ create(:ci_job_artifact, :junit_with_ant, job: build_java, project: project)
+ end
+
+ it 'returns test report count equal to test reports total_count' do
+ expect(subject.total_count).to eq(7)
+ expect(subject.total_count).to eq(pipeline.test_reports_count)
+ end
+
+ it 'reads from cache when records are cached' do
+ expect(Rails.cache.fetch(['project', project.id, 'pipeline', pipeline.id, 'test_reports_count'], force: false)).to be_nil
+
+ pipeline.test_reports_count
+
+ expect(ActiveRecord::QueryRecorder.new { pipeline.test_reports_count }.count).to eq(0)
+ end
+ end
+
+ context 'when pipeline does not have any builds with test reports' do
+ it 'returns empty test report count' do
+ expect(subject.total_count).to eq(0)
+ expect(subject.total_count).to eq(pipeline.test_reports_count)
+ end
+ end
+ end
+
describe '#total_size' do
let!(:build_job1) { create(:ci_build, pipeline: pipeline, stage_idx: 0) }
let!(:build_job2) { create(:ci_build, pipeline: pipeline, stage_idx: 0) }