summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-14 08:12:27 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-14 08:12:27 +0000
commit3772445de3063dda5e5fb2f21b6debf14032cc92 (patch)
tree8db2e49b644638f160392062221e6a0a56fcfd62 /spec/controllers
parent28a9333b4b418ce3f96fcd0a530d76ac86e6c4ed (diff)
downloadgitlab-ce-3772445de3063dda5e5fb2f21b6debf14032cc92.tar.gz
Add latest changes from gitlab-org/gitlab@13-11-stable-ee
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/projects/pipelines_controller_spec.rb33
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) }