summaryrefslogtreecommitdiff
path: root/spec/graphql/gitlab_schema_spec.rb
diff options
context:
space:
mode:
authorMarcel Amirault <mamirault@gitlab.com>2019-07-10 05:56:23 +0000
committerMarcel Amirault <mamirault@gitlab.com>2019-07-10 05:56:23 +0000
commit2b03a0c2cf699074ec37a863e5c752a2cab2b133 (patch)
tree7ebc289d2ec498fcebf8ae454cdb1eb1ef500dbd /spec/graphql/gitlab_schema_spec.rb
parentc0deda7a86796c5de6ebe376c83f55af0965bde3 (diff)
parent810df4fb51bf3db4016c5f7458599331d4586300 (diff)
downloadgitlab-ce-docs-hard-tabs.tar.gz
Merge branch 'master' into 'docs-hard-tabs'docs-hard-tabs
# Conflicts: # doc/administration/pseudonymizer.md # doc/administration/uploads.md
Diffstat (limited to 'spec/graphql/gitlab_schema_spec.rb')
-rw-r--r--spec/graphql/gitlab_schema_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/graphql/gitlab_schema_spec.rb b/spec/graphql/gitlab_schema_spec.rb
index 93b86b9b812..dec6b23d72a 100644
--- a/spec/graphql/gitlab_schema_spec.rb
+++ b/spec/graphql/gitlab_schema_spec.rb
@@ -143,6 +143,26 @@ describe GitlabSchema do
end
end
+ context 'for classes that are not ActiveRecord subclasses and have implemented .lazy_find' do
+ it 'returns the correct record' do
+ note = create(:discussion_note_on_merge_request)
+
+ result = described_class.object_from_id(note.to_global_id)
+
+ expect(result.__sync).to eq(note)
+ end
+
+ it 'batchloads the queries' do
+ note1 = create(:discussion_note_on_merge_request)
+ note2 = create(:discussion_note_on_merge_request)
+
+ expect do
+ [described_class.object_from_id(note1.to_global_id),
+ described_class.object_from_id(note2.to_global_id)].map(&:__sync)
+ end.not_to exceed_query_limit(1)
+ end
+ end
+
context 'for other classes' do
# We cannot use an anonymous class here as `GlobalID` expects `.name` not
# to return `nil`