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/support/shared_examples/controllers/environments_controller_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/controllers/environments_controller_shared_examples.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/support/shared_examples/controllers/environments_controller_shared_examples.rb b/spec/support/shared_examples/controllers/environments_controller_shared_examples.rb
index c6e880635aa..a79b94209f3 100644
--- a/spec/support/shared_examples/controllers/environments_controller_shared_examples.rb
+++ b/spec/support/shared_examples/controllers/environments_controller_shared_examples.rb
@@ -65,3 +65,20 @@ RSpec.shared_examples 'failed response for #cancel_auto_stop' do
end
end
end
+
+RSpec.shared_examples 'avoids N+1 queries on environment detail page' do
+ render_views
+
+ before do
+ create_deployment_with_associations(sequence: 0)
+ end
+
+ it 'avoids N+1 queries' do
+ control = ActiveRecord::QueryRecorder.new { get :show, params: environment_params }
+
+ create_deployment_with_associations(sequence: 1)
+ create_deployment_with_associations(sequence: 2)
+
+ expect { get :show, params: environment_params }.not_to exceed_query_limit(control.count).with_threshold(34)
+ end
+end