diff options
author | Brett Walker <bwalker@gitlab.com> | 2019-05-21 00:19:00 +0300 |
---|---|---|
committer | Brett Walker <bwalker@gitlab.com> | 2019-05-21 01:23:11 +0300 |
commit | 0f14b628c4e9624c42e783c0e6620e8b00073ab6 (patch) | |
tree | e19c7d187c982101ba3ddb279054ad1b3458f6f8 /spec/graphql/resolvers | |
parent | d951f047198d3ee03604fb64f6ad96efae6cba54 (diff) |
Use BatchModelLoader for parent in GroupType
Diffstat (limited to 'spec/graphql/resolvers')
-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 |