diff options
author | Phil Hughes <me@iamphill.com> | 2019-05-22 14:43:35 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2019-05-22 14:43:35 +0300 |
commit | 67a50861953be9347e267795a9ce736dfea5316b (patch) | |
tree | b9546274a629204b8c2ae9a60c5da70ae3a06ba7 /spec/graphql/resolvers | |
parent | c841c8771b8d69034c1ceb6e452746d193865cb0 (diff) |
Added repository files to GraphQL API
Diffstat (limited to 'spec/graphql/resolvers')
-rw-r--r-- | spec/graphql/resolvers/tree_resolver_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/graphql/resolvers/tree_resolver_spec.rb b/spec/graphql/resolvers/tree_resolver_spec.rb new file mode 100644 index 00000000000..9f95b740ab1 --- /dev/null +++ b/spec/graphql/resolvers/tree_resolver_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe Resolvers::TreeResolver do + 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 |