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

environments_controller_spec_shared_examples.rb « projects « requests « shared_examples « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 31218b104bd1dc8bce7091582da88a6d907bd1bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

RSpec.shared_examples 'avoids N+1 queries on environment detail page' do
  it 'avoids N+1 queries', :use_sql_query_cache do
    create_deployment_with_associations(commit_depth: 19)

    control = ActiveRecord::QueryRecorder.new(skip_cached: false) do
      get project_environment_path(project, environment), params: environment_params
    end

    18.downto(0).each { |n| create_deployment_with_associations(commit_depth: n) }

    # N+1s exist for loading commit emails and users
    expect do
      get project_environment_path(project, environment), params: environment_params
    end.not_to exceed_all_query_limit(control).with_threshold(9)
  end
end