diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 23:50:22 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 23:50:22 +0000 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /spec/controllers/groups/labels_controller_spec.rb | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) | |
download | gitlab-ce-13.11.0-rc43.tar.gz |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'spec/controllers/groups/labels_controller_spec.rb')
-rw-r--r-- | spec/controllers/groups/labels_controller_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/controllers/groups/labels_controller_spec.rb b/spec/controllers/groups/labels_controller_spec.rb index b2320615778..90da40cd5f0 100644 --- a/spec/controllers/groups/labels_controller_spec.rb +++ b/spec/controllers/groups/labels_controller_spec.rb @@ -46,6 +46,24 @@ RSpec.describe Groups::LabelsController do it_behaves_like 'disabled when using an external authorization service' end + + context 'with views rendered' do + render_views + + before do + get :index, params: { group_id: group.to_param } + end + + it 'avoids N+1 queries' do + control = ActiveRecord::QueryRecorder.new(skip_cached: false) { get :index, params: { group_id: group.to_param } } + + create_list(:group_label, 3, group: group) + + # some n+1 queries still exist + expect { get :index, params: { group_id: group.to_param } }.not_to exceed_all_query_limit(control.count).with_threshold(10) + expect(assigns(:labels).count).to eq(4) + end + end end describe 'POST #toggle_subscription' do |