diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/requests/api/graphql/project/alert_management/alert/notes_spec.rb | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) | |
download | gitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/requests/api/graphql/project/alert_management/alert/notes_spec.rb')
-rw-r--r-- | spec/requests/api/graphql/project/alert_management/alert/notes_spec.rb | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/spec/requests/api/graphql/project/alert_management/alert/notes_spec.rb b/spec/requests/api/graphql/project/alert_management/alert/notes_spec.rb index 1350cba119b..5d46f370756 100644 --- a/spec/requests/api/graphql/project/alert_management/alert/notes_spec.rb +++ b/spec/requests/api/graphql/project/alert_management/alert/notes_spec.rb @@ -65,16 +65,28 @@ RSpec.describe 'getting Alert Management Alert Notes' do expect(second_notes_result).to be_empty end - it 'avoids N+1 queries' do - base_count = ActiveRecord::QueryRecorder.new do - post_graphql(query, current_user: current_user) + describe 'performance' do + let(:first_n) { var('Int') } + let(:params) { { first: first_n } } + + before do + # An N+1 would mean a new alert would increase the query count + create(:alert_management_alert, project: project) end - # An N+1 would mean a new alert would increase the query count - create(:alert_management_alert, project: project) + it 'avoids N+1 queries' do + q = with_signature([first_n], query) - expect { post_graphql(query, current_user: current_user) }.not_to exceed_query_limit(base_count) - expect(alerts_result.length).to eq(3) + base_count = ActiveRecord::QueryRecorder.new do + post_graphql(q, current_user: current_user, variables: first_n.with(1)) + expect(alerts_result.length).to eq(1) + end + + expect do + post_graphql(q, current_user: current_user, variables: first_n.with(3)) + expect(alerts_result.length).to eq(3) + end.not_to exceed_query_limit(base_count) + end end context 'for non-system notes' do |