Add failing test showing N+1

We have an N+1 problem where N is environments.
This commit is contained in:
Thong Kuah 2019-06-20 14:03:21 +12:00
parent bd69c9197c
commit 72339077f7
1 changed files with 12 additions and 0 deletions

View File

@ -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,