2017-08-16 09:04:41 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-05-23 03:55:14 -04:00
|
|
|
describe Resolvers::ProjectResolver do
|
2017-08-16 09:04:41 -04:00
|
|
|
include GraphqlHelpers
|
|
|
|
|
|
|
|
set(:project1) { create(:project) }
|
|
|
|
set(:project2) { create(:project) }
|
|
|
|
|
|
|
|
set(:other_project) { create(:project) }
|
|
|
|
|
2018-05-23 03:55:14 -04:00
|
|
|
describe '#resolve' do
|
2017-08-16 09:04:41 -04:00
|
|
|
it 'batch-resolves projects by full path' do
|
|
|
|
paths = [project1.full_path, project2.full_path]
|
|
|
|
|
|
|
|
result = batch(max_queries: 1) do
|
|
|
|
paths.map { |path| resolve_project(path) }
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(result).to contain_exactly(project1, project2)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'resolves an unknown full_path to nil' do
|
|
|
|
result = batch { resolve_project('unknown/project') }
|
|
|
|
|
|
|
|
expect(result).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def resolve_project(full_path)
|
2018-05-23 03:55:14 -04:00
|
|
|
resolve(described_class, args: { full_path: full_path })
|
2017-08-16 09:04:41 -04:00
|
|
|
end
|
|
|
|
end
|