diff options
Diffstat (limited to 'spec/graphql')
-rw-r--r-- | spec/graphql/resolvers/repository_branch_names_resolver_spec.rb | 36 | ||||
-rw-r--r-- | spec/graphql/types/repository_type_spec.rb | 2 |
2 files changed, 38 insertions, 0 deletions
diff --git a/spec/graphql/resolvers/repository_branch_names_resolver_spec.rb b/spec/graphql/resolvers/repository_branch_names_resolver_spec.rb new file mode 100644 index 00000000000..398dd7a2e2e --- /dev/null +++ b/spec/graphql/resolvers/repository_branch_names_resolver_spec.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Resolvers::RepositoryBranchNamesResolver do + include GraphqlHelpers + + let(:project) { create(:project, :repository) } + + describe '#resolve' do + subject(:resolve_branch_names) do + resolve( + described_class, + obj: project.repository, + args: { search_pattern: pattern }, + ctx: { current_user: project.creator } + ) + end + + context 'with empty search pattern' do + let(:pattern) { '' } + + it 'returns nil' do + expect(resolve_branch_names).to eq(nil) + end + end + + context 'with a valid search pattern' do + let(:pattern) { 'mas*' } + + it 'returns matching branches' do + expect(resolve_branch_names).to match_array(['master']) + end + end + end +end diff --git a/spec/graphql/types/repository_type_spec.rb b/spec/graphql/types/repository_type_spec.rb index a3bb7e502f2..fa1e54dfcfa 100644 --- a/spec/graphql/types/repository_type_spec.rb +++ b/spec/graphql/types/repository_type_spec.rb @@ -14,4 +14,6 @@ RSpec.describe GitlabSchema.types['Repository'] do specify { expect(described_class).to have_graphql_field(:exists, calls_gitaly?: true, complexity: 2) } specify { expect(described_class).to have_graphql_field(:blobs) } + + specify { expect(described_class).to have_graphql_field(:branch_names, calls_gitaly?: true, complexity: 170) } end |