Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests/projects/pipelines_controller_spec.rb')
-rw-r--r--spec/requests/projects/pipelines_controller_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/requests/projects/pipelines_controller_spec.rb b/spec/requests/projects/pipelines_controller_spec.rb
index 7f185ade339..73e002b63b1 100644
--- a/spec/requests/projects/pipelines_controller_spec.rb
+++ b/spec/requests/projects/pipelines_controller_spec.rb
@@ -19,6 +19,32 @@ RSpec.describe Projects::PipelinesController, feature_category: :continuous_inte
login_as(user)
end
+ describe "GET index.json" do
+ it 'does not execute N+1 queries' do
+ get_pipelines_index
+
+ control_count = ActiveRecord::QueryRecorder.new do
+ get_pipelines_index
+ end.count
+
+ %w[pending running success failed canceled].each do |status|
+ create(:ci_pipeline, project: project, status: status)
+ end
+
+ # There appears to be one extra query for Pipelines#has_warnings? for some reason
+ expect { get_pipelines_index }.not_to exceed_query_limit(control_count + 1)
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['pipelines'].count).to eq 6
+ end
+
+ def get_pipelines_index
+ get namespace_project_pipelines_path(
+ namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ format: :json)
+ end
+ end
+
describe "GET stages.json" do
it 'does not execute N+1 queries' do
request_build_stage