summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorThong Kuah <tkuah@gitlab.com>2019-06-20 14:03:21 +1200
committerThong Kuah <tkuah@gitlab.com>2019-07-08 09:13:21 +1200
commit72339077f7d79eeb9d0612c55236aa4aa6da4084 (patch)
tree28dd100fb1dbef4bbed520e15210d13f759fc862 /spec
parentbd69c9197cefcb31ebabe466df005f1451ac1c46 (diff)
downloadgitlab-ce-72339077f7d79eeb9d0612c55236aa4aa6da4084.tar.gz
Add failing test showing N+1
We have an N+1 problem where N is environments.
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/projects/merge_requests_controller_spec.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb
index 0eca663a683..1120bf6dcb0 100644
--- a/spec/controllers/projects/merge_requests_controller_spec.rb
+++ b/spec/controllers/projects/merge_requests_controller_spec.rb
@@ -878,6 +878,18 @@ describe Projects::MergeRequestsController do
expect(control_count).to be <= 137
end
+ it 'has no N+1 issues for environments', :request_store do
+ # First run to insert test data from lets, which does take up some 30 queries
+ get_ci_environments_status
+
+ control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) { get_ci_environments_status }.count
+
+ environment2 = create(:environment, project: forked)
+ create(:deployment, :succeed, environment: environment2, sha: sha, ref: 'master', deployable: build)
+
+ expect { get_ci_environments_status }.not_to exceed_all_query_limit(control_count)
+ end
+
def get_ci_environments_status(extra_params = {})
params = {
namespace_id: merge_request.project.namespace.to_param,