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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 21:42:06 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 21:42:06 +0300
commit6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch)
tree78be5963ec075d80116a932011d695dd33910b4e /spec/controllers/explore
parent1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff)
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/controllers/explore')
-rw-r--r--spec/controllers/explore/projects_controller_spec.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/controllers/explore/projects_controller_spec.rb b/spec/controllers/explore/projects_controller_spec.rb
index fd86501ff5d..4ec890a528f 100644
--- a/spec/controllers/explore/projects_controller_spec.rb
+++ b/spec/controllers/explore/projects_controller_spec.rb
@@ -138,6 +138,33 @@ RSpec.describe Explore::ProjectsController do
end
end
+ shared_examples 'avoids N+1 queries' do
+ [:index, :trending, :starred].each do |endpoint|
+ describe "GET #{endpoint}" do
+ render_views
+
+ # some N+1 queries still exist
+ it 'avoids N+1 queries' do
+ projects = create_list(:project, 3, :repository, :public)
+ projects.each do |project|
+ pipeline = create(:ci_pipeline, :success, project: project, sha: project.commit.id)
+ create(:commit_status, :success, pipeline: pipeline, ref: pipeline.ref)
+ end
+
+ control = ActiveRecord::QueryRecorder.new { get endpoint }
+
+ new_projects = create_list(:project, 2, :repository, :public)
+ new_projects.each do |project|
+ pipeline = create(:ci_pipeline, :success, project: project, sha: project.commit.id)
+ create(:commit_status, :success, pipeline: pipeline, ref: pipeline.ref)
+ end
+
+ expect { get endpoint }.not_to exceed_query_limit(control).with_threshold(8)
+ end
+ end
+ end
+ end
+
context 'when user is signed in' do
let(:user) { create(:user) }
@@ -147,6 +174,7 @@ RSpec.describe Explore::ProjectsController do
include_examples 'explore projects'
include_examples "blocks high page numbers"
+ include_examples 'avoids N+1 queries'
context 'user preference sorting' do
let(:project) { create(:project) }
@@ -160,6 +188,7 @@ RSpec.describe Explore::ProjectsController do
context 'when user is not signed in' do
include_examples 'explore projects'
include_examples "blocks high page numbers"
+ include_examples 'avoids N+1 queries'
context 'user preference sorting' do
let(:project) { create(:project) }