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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-12-18 03:14:00 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-12-18 03:14:00 +0300
commite1d036885e2f5720e847d9009f60c5d7baad0015 (patch)
tree2fd1a36b792ff2e7d71944d28cb1473dfe22cde4 /spec/graphql/resolvers
parent6bdb805dc87064d97d303ce8864f30e48663c6e9 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql/resolvers')
-rw-r--r--spec/graphql/resolvers/users/participants_resolver_spec.rb30
1 files changed, 23 insertions, 7 deletions
diff --git a/spec/graphql/resolvers/users/participants_resolver_spec.rb b/spec/graphql/resolvers/users/participants_resolver_spec.rb
index 77e3b6d5912..3f04d157410 100644
--- a/spec/graphql/resolvers/users/participants_resolver_spec.rb
+++ b/spec/graphql/resolvers/users/participants_resolver_spec.rb
@@ -13,6 +13,7 @@ RSpec.describe Resolvers::Users::ParticipantsResolver do
let_it_be(:note) do
create(
:note,
+ :system,
:confidential,
project: project,
noteable: issue,
@@ -20,6 +21,8 @@ RSpec.describe Resolvers::Users::ParticipantsResolver do
)
end
+ let_it_be(:note_metadata) { create(:system_note_metadata, note: note) }
+
subject(:resolved_items) { resolve(described_class, args: {}, ctx: { current_user: current_user }, obj: issue)&.items }
before do
@@ -50,17 +53,30 @@ RSpec.describe Resolvers::Users::ParticipantsResolver do
is_expected.to match_array([issue.author, note.author])
end
- it 'does not execute N+1 for project relation' do
- query = -> { resolve(described_class, args: {}, ctx: { current_user: current_user }, obj: issue)&.items }
+ context 'N+1 queries' do
+ let(:query) { -> { resolve(described_class, args: {}, ctx: { current_user: current_user }, obj: issue)&.items } }
+
+ before do
+ # warm-up
+ query.call
+ end
+
+ it 'does not execute N+1 for project relation' do
+ control_count = ActiveRecord::QueryRecorder.new { query.call }
+
+ create(:note, :confidential, project: project, noteable: issue, author: create(:user))
- # warm-up
- query.call
+ expect { query.call }.not_to exceed_query_limit(control_count)
+ end
- control_count = ActiveRecord::QueryRecorder.new { query.call }
+ it 'does not execute N+1 for system note metadata relation' do
+ control_count = ActiveRecord::QueryRecorder.new { query.call }
- create(:note, :confidential, project: project, noteable: issue, author: create(:user))
+ new_note = create(:note, :system, project: project, noteable: issue, author: create(:user))
+ create(:system_note_metadata, note: new_note)
- expect { query.call }.not_to exceed_query_limit(control_count)
+ expect { query.call }.not_to exceed_query_limit(control_count)
+ end
end
end
end