diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-14 11:12:27 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-14 11:12:27 +0300 |
commit | 3772445de3063dda5e5fb2f21b6debf14032cc92 (patch) | |
tree | 8db2e49b644638f160392062221e6a0a56fcfd62 /spec/controllers/projects | |
parent | 28a9333b4b418ce3f96fcd0a530d76ac86e6c4ed (diff) |
Add latest changes from gitlab-org/gitlab@13-11-stable-ee
Diffstat (limited to 'spec/controllers/projects')
-rw-r--r-- | spec/controllers/projects/pipelines_controller_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb index 753223c5a4f..4a1d01f0e82 100644 --- a/spec/controllers/projects/pipelines_controller_spec.rb +++ b/spec/controllers/projects/pipelines_controller_spec.rb @@ -290,6 +290,39 @@ RSpec.describe Projects::PipelinesController do end end + describe 'GET #show' do + render_views + + let_it_be(:pipeline) { create(:ci_pipeline, project: project) } + + subject { get_pipeline_html } + + def get_pipeline_html + get :show, params: { namespace_id: project.namespace, project_id: project, id: pipeline }, format: :html + end + + def create_build_with_artifacts(stage, stage_idx, name) + create(:ci_build, :artifacts, :tags, pipeline: pipeline, stage: stage, stage_idx: stage_idx, name: name) + end + + before do + create_build_with_artifacts('build', 0, 'job1') + create_build_with_artifacts('build', 0, 'job2') + end + + it 'avoids N+1 database queries', :request_store do + get_pipeline_html + + control_count = ActiveRecord::QueryRecorder.new { get_pipeline_html }.count + expect(response).to have_gitlab_http_status(:ok) + + create_build_with_artifacts('build', 0, 'job3') + + expect { get_pipeline_html }.not_to exceed_query_limit(control_count) + expect(response).to have_gitlab_http_status(:ok) + end + end + describe 'GET show.json' do let(:pipeline) { create(:ci_pipeline, project: project) } |