diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-18 09:09:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-18 09:09:06 +0300 |
commit | cefe554b7ce2d0b52f9de855be832a47c2bc24ab (patch) | |
tree | 74c1ad2f688afd2f806aaf94e73e0bcd128cea00 /spec/serializers/pipeline_details_entity_spec.rb | |
parent | 5ee120f46740efac7b8a460d7a92e4da82f4fb0b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/serializers/pipeline_details_entity_spec.rb')
-rw-r--r-- | spec/serializers/pipeline_details_entity_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/serializers/pipeline_details_entity_spec.rb b/spec/serializers/pipeline_details_entity_spec.rb index 9ce7c265e43..f270f9fd4cb 100644 --- a/spec/serializers/pipeline_details_entity_spec.rb +++ b/spec/serializers/pipeline_details_entity_spec.rb @@ -173,5 +173,44 @@ describe PipelineDetailsEntity do expect(subject[:triggered].first[:project]).not_to be_nil end end + + context 'when pipeline has expiring archive artifacts' do + let(:pipeline) { create(:ci_empty_pipeline) } + let!(:build_1) { create(:ci_build, :artifacts, pipeline: pipeline, artifacts_expire_at: 2.days.from_now, name: 'build_1') } + let!(:build_2) { create(:ci_build, :artifacts, pipeline: pipeline, artifacts_expire_at: 2.days.from_now, name: 'build_2') } + let!(:build_3) { create(:ci_build, :artifacts, pipeline: pipeline, artifacts_expire_at: 2.days.from_now, name: 'build_3') } + + let(:names) { subject[:details][:artifacts].map { |a| a[:name] } } + + context 'and preload_job_artifacts_archive is not defined in the options' do + it 'defaults to true and eager loads the job_artifacts_archive' do + recorder = ActiveRecord::QueryRecorder.new do + expect(names).to match_array(%w[build_1 build_2 build_3]) + end + + expected_queries = Gitlab.ee? ? 42 : 29 + + # This makes only one query to fetch all job artifacts + expect(recorder.count).to eq(expected_queries) + end + end + + context 'and preload_job_artifacts_archive is set to false' do + let(:entity) do + described_class.represent(pipeline, request: request, preload_job_artifacts_archive: false) + end + + it 'does not eager load the job_artifacts_archive' do + recorder = ActiveRecord::QueryRecorder.new do + expect(names).to match_array(%w[build_1 build_2 build_3]) + end + + expected_queries = Gitlab.ee? ? 44 : 31 + + # This makes one query for each job artifact + expect(recorder.count).to eq(expected_queries) + end + end + end end end |