2019-10-17 05:07:07 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-05-22 07:43:35 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 05:08:32 -04:00
|
|
|
RSpec.describe Resolvers::TreeResolver do
|
2019-05-22 07:43:35 -04:00
|
|
|
include GraphqlHelpers
|
|
|
|
|
|
|
|
let(:repository) { create(:project, :repository).repository }
|
|
|
|
|
|
|
|
describe '#resolve' do
|
|
|
|
it 'resolves to a tree' do
|
|
|
|
result = resolve_repository({ ref: "master" })
|
|
|
|
|
|
|
|
expect(result).to be_an_instance_of(Tree)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'resolve to a recursive tree' do
|
|
|
|
result = resolve_repository({ ref: "master", recursive: true })
|
|
|
|
|
|
|
|
expect(result.trees[4].path).to eq('files/html')
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when repository does not exist' do
|
|
|
|
it 'returns nil' do
|
|
|
|
allow(repository).to receive(:exists?).and_return(false)
|
|
|
|
|
|
|
|
result = resolve_repository({ ref: "master" })
|
|
|
|
|
|
|
|
expect(result).to be(nil)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def resolve_repository(args)
|
|
|
|
resolve(described_class, obj: repository, args: args)
|
|
|
|
end
|
|
|
|
end
|