query_type_spec.rb 1.04 KB
Newer Older
Nick Thomas's avatar
Nick Thomas committed
1
2
3
4
require 'spec_helper'

describe GitlabSchema.types['Query'] do
  it 'is called Query' do
5
    expect(described_class.graphql_name).to eq('Query')
Nick Thomas's avatar
Nick Thomas committed
6
7
  end

8
  it { is_expected.to have_graphql_fields(:project, :echo, :metadata) }
Nick Thomas's avatar
Nick Thomas committed
9
10
11
12
13
14
15

  describe 'project field' do
    subject { described_class.fields['project'] }

    it 'finds projects by full path' do
      is_expected.to have_graphql_arguments(:full_path)
      is_expected.to have_graphql_type(Types::ProjectType)
16
      is_expected.to have_graphql_resolver(Resolvers::ProjectResolver)
Nick Thomas's avatar
Nick Thomas committed
17
18
19
20
21
22
    end

    it 'authorizes with read_project' do
      is_expected.to require_graphql_authorizations(:read_project)
    end
  end
23
24
25
26
27
28
29
30
31

  describe 'metadata field' do
    subject { described_class.fields['metadata'] }

    it 'returns metadata' do
      is_expected.to have_graphql_type(Types::MetadataType)
      is_expected.to have_graphql_resolver(Resolvers::MetadataResolver)
    end

32
    it 'authorizes with read_instance_metadata' do
33
34
35
      is_expected.to require_graphql_authorizations(:read_instance_metadata)
    end
  end
Nick Thomas's avatar
Nick Thomas committed
36
end