blob: 3a062d77b4fd053c4a6045cfd5bc90812b6c59e6 (
plain)
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
RSpec.shared_context 'with work item types request context' do
let(:work_item_type_fields) do
<<~GRAPHQL
id
name
iconName
widgetDefinitions {
type
... on WorkItemWidgetDefinitionAssignees {
canInviteMembers
}
... on WorkItemWidgetDefinitionHierarchy {
allowedChildTypes {
nodes { id name }
}
}
}
GRAPHQL
end
# This is necessary so we can overwrite attributes in EE
let(:widget_attributes) { base_widget_attributes }
let(:base_widget_attributes) do
{
assignees: {
'canInviteMembers' => false
}
}
end
def expected_work_item_type_response(work_item_type = nil)
base_scope = WorkItems::Type.default
base_scope = base_scope.id_in(work_item_type.id) if work_item_type
base_scope.map do |type|
hash_including(
'id' => type.to_global_id.to_s,
'name' => type.name,
'iconName' => type.icon_name,
'widgetDefinitions' => match_array(widgets_for(type))
)
end
end
def widgets_for(work_item_type)
work_item_type.widgets.map do |widget|
base_attributes = { 'type' => widget.type.to_s.upcase }
next hierarchy_widget_attributes(work_item_type, base_attributes) if widget == WorkItems::Widgets::Hierarchy
next base_attributes unless widget_attributes[widget.type]
base_attributes.merge(widget_attributes[widget.type])
end
end
def hierarchy_widget_attributes(work_item_type, base_attributes)
fields = work_item_type.allowed_child_types_by_name.map do |child_type|
{ "id" => child_type.to_global_id.to_s, "name" => child_type.name }
end
base_attributes.merge({ 'allowedChildTypes' => { 'nodes' => fields } })
end
end
|