2019-05-20 17:19:00 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 05:08:32 -04:00
|
|
|
RSpec.describe Resolvers::GroupResolver do
|
2019-05-20 17:19:00 -04:00
|
|
|
include GraphqlHelpers
|
|
|
|
|
2020-02-18 10:08:51 -05:00
|
|
|
let_it_be(:group1) { create(:group) }
|
|
|
|
let_it_be(:group2) { create(:group) }
|
2019-05-20 17:19:00 -04:00
|
|
|
|
|
|
|
describe '#resolve' do
|
|
|
|
it 'batch-resolves groups by full path' do
|
|
|
|
paths = [group1.full_path, group2.full_path]
|
|
|
|
|
2019-09-04 13:42:48 -04:00
|
|
|
result = batch_sync(max_queries: 1) do
|
2019-05-20 17:19:00 -04:00
|
|
|
paths.map { |path| resolve_group(path) }
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(result).to contain_exactly(group1, group2)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'resolves an unknown full_path to nil' do
|
2019-09-04 13:42:48 -04:00
|
|
|
result = batch_sync { resolve_group('unknown/project') }
|
2019-05-20 17:19:00 -04:00
|
|
|
|
|
|
|
expect(result).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def resolve_group(full_path)
|
|
|
|
resolve(described_class, args: { full_path: full_path })
|
|
|
|
end
|
|
|
|
end
|