1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GitlabSchema.types['SnippetBlob'] do
include GraphqlHelpers
it 'has the correct fields' do
expected_fields = [:rich_data, :plain_data,
:raw_path, :size, :binary, :name, :path,
:simple_viewer, :rich_viewer, :mode, :external_storage,
:rendered_as_text]
expect(described_class).to have_graphql_fields(*expected_fields)
end
let_it_be(:nullity) do
{
'richData' => be_nullable,
'plainData' => be_nullable,
'rawPath' => be_non_null,
'size' => be_non_null,
'binary' => be_non_null,
'name' => be_nullable,
'path' => be_nullable,
'simpleViewer' => be_non_null,
'richViewer' => be_nullable,
'mode' => be_nullable,
'externalStorage' => be_nullable,
'renderedAsText' => be_non_null
}
end
let_it_be(:blob) { create(:snippet, :public, :repository).blobs.first }
shared_examples 'a field from the snippet blob presenter' do |field|
it "resolves using the presenter", :request_store do
presented = SnippetBlobPresenter.new(blob)
expect(resolve_field(field, blob)).to eq(presented.try(field.method_sym))
end
end
described_class.fields.each_value do |field|
describe field.graphql_name do
it_behaves_like 'a field from the snippet blob presenter', field
specify { expect(field.type).to match(nullity.fetch(field.graphql_name)) }
end
end
end
|