diff options
author | Sean McGivern <sean@gitlab.com> | 2019-05-21 12:39:38 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-05-21 12:39:38 +0000 |
commit | 4cf3a176da199b3f1fd874b3ba118e0ca2495939 (patch) | |
tree | bed28541e9094d0daacf24e565db8ee7993e8f7e /spec | |
parent | e1625a3bf0a6f7b907876932dcc2b0bda3fe140f (diff) | |
parent | 0f14b628c4e9624c42e783c0e6620e8b00073ab6 (diff) | |
download | gitlab-ce-4cf3a176da199b3f1fd874b3ba118e0ca2495939.tar.gz |
Merge branch '62066-use-batchmodelloader-for-grouptype' into 'master'
Use `BatchModelLoader` for GroupType
Closes #62066
See merge request gitlab-org/gitlab-ce!28504
Diffstat (limited to 'spec')
-rw-r--r-- | spec/graphql/resolvers/group_resolver_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/graphql/resolvers/group_resolver_spec.rb b/spec/graphql/resolvers/group_resolver_spec.rb new file mode 100644 index 00000000000..5eb9cd06d15 --- /dev/null +++ b/spec/graphql/resolvers/group_resolver_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Resolvers::GroupResolver do + include GraphqlHelpers + + set(:group1) { create(:group) } + set(:group2) { create(:group) } + + describe '#resolve' do + it 'batch-resolves groups by full path' do + paths = [group1.full_path, group2.full_path] + + result = batch(max_queries: 1) do + paths.map { |path| resolve_group(path) } + end + + expect(result).to contain_exactly(group1, group2) + end + + it 'resolves an unknown full_path to nil' do + result = batch { resolve_group('unknown/project') } + + expect(result).to be_nil + end + end + + def resolve_group(full_path) + resolve(described_class, args: { full_path: full_path }) + end +end |