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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Getting designs related to an issue' do
include GraphqlHelpers
include DesignManagementTestHelpers
let_it_be(:project) { create(:project, :public) }
let_it_be(:issue) { create(:issue, project: project) }
let_it_be(:design) { create(:design, :with_file, versions_count: 1, issue: issue) }
let_it_be(:current_user) { project.owner }
let_it_be(:note) { create(:diff_note_on_design, noteable: design, project: project) }
before do
enable_design_management
end
it_behaves_like 'a working graphql query' do
before do
post_graphql(query, current_user: current_user)
end
end
it 'is not too deep for anonymous users' do
note_fields = <<~FIELDS
id
author { name }
FIELDS
post_graphql(query(note_fields), current_user: nil)
designs_data = graphql_data['project']['issue']['designs']['designs']
design_data = designs_data['nodes'].first
note_data = design_data['notes']['nodes'].first
expect(note_data['id']).to eq(note.to_global_id.to_s)
end
def query(note_fields = all_graphql_fields_for(Note))
design_node = <<~NODE
designs {
nodes {
notes {
nodes {
#{note_fields}
}
}
}
}
NODE
graphql_query_for(
'project',
{ 'fullPath' => design.project.full_path },
query_graphql_field(
'issue',
{ iid: design.issue.iid.to_s },
query_graphql_field(
'designs', {}, design_node
)
)
)
end
end
|