diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/support/shared_examples/controllers | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/support/shared_examples/controllers')
-rw-r--r-- | spec/support/shared_examples/controllers/environments_controller_shared_examples.rb | 17 | ||||
-rw-r--r-- | spec/support/shared_examples/controllers/repository_lfs_file_load_shared_examples.rb | 6 |
2 files changed, 21 insertions, 2 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 diff --git a/spec/support/shared_examples/controllers/repository_lfs_file_load_shared_examples.rb b/spec/support/shared_examples/controllers/repository_lfs_file_load_shared_examples.rb index fadf428125a..9cf35325202 100644 --- a/spec/support/shared_examples/controllers/repository_lfs_file_load_shared_examples.rb +++ b/spec/support/shared_examples/controllers/repository_lfs_file_load_shared_examples.rb @@ -44,8 +44,10 @@ RSpec.shared_examples 'a controller that can serve LFS files' do |options = {}| expect(controller).to receive(:send_file) .with( File.join(lfs_uploader.root, lfs_uploader.store_dir, lfs_uploader.filename), - filename: filename, - disposition: 'attachment') + { + filename: filename, + disposition: 'attachment' + }) subject |