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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::ImportExport::Config do
let(:yaml_file) { described_class.new }
describe '#to_h' do
context 'when using CE' do
before do
allow(yaml_file)
.to receive(:merge?)
.and_return(false)
end
it 'just returns the parsed Hash without the EE section' do
expected = YAML.load_file(Gitlab::ImportExport.config_file)
expected.delete('ee')
expect(yaml_file.to_h).to eq(expected)
end
end
context 'when using EE' do
before do
allow(yaml_file)
.to receive(:merge?)
.and_return(true)
end
it 'merges the EE project tree into the CE project tree' do
allow(yaml_file)
.to receive(:parse_yaml)
.and_return({
'project_tree' => [
{
'issues' => [
:id,
:title,
{ 'notes' => [:id, :note, { 'author' => [:name] }] }
]
}
],
'ee' => {
'project_tree' => [
{
'issues' => [
:description,
{ 'notes' => [:date, { 'author' => [:email] }] }
]
},
{ 'foo' => [{ 'bar' => %i[baz] }] }
]
}
})
expect(yaml_file.to_h).to eq({
'project_tree' => [
{
'issues' => [
:id,
:title,
{
'notes' => [
:id,
:note,
{ 'author' => [:name, :email] },
:date
]
},
:description
]
},
{ 'foo' => [{ 'bar' => %i[baz] }] }
]
})
end
it 'merges the excluded attributes list' do
allow(yaml_file)
.to receive(:parse_yaml)
.and_return({
'project_tree' => [],
'excluded_attributes' => {
'project' => %i[id title],
'notes' => %i[id]
},
'ee' => {
'project_tree' => [],
'excluded_attributes' => {
'project' => %i[date],
'foo' => %i[bar baz]
}
}
})
expect(yaml_file.to_h).to eq({
'project_tree' => [],
'excluded_attributes' => {
'project' => %i[id title date],
'notes' => %i[id],
'foo' => %i[bar baz]
}
})
end
it 'merges the included attributes list' do
allow(yaml_file)
.to receive(:parse_yaml)
.and_return({
'project_tree' => [],
'included_attributes' => {
'project' => %i[id title],
'notes' => %i[id]
},
'ee' => {
'project_tree' => [],
'included_attributes' => {
'project' => %i[date],
'foo' => %i[bar baz]
}
}
})
expect(yaml_file.to_h).to eq({
'project_tree' => [],
'included_attributes' => {
'project' => %i[id title date],
'notes' => %i[id],
'foo' => %i[bar baz]
}
})
end
it 'merges the methods list' do
allow(yaml_file)
.to receive(:parse_yaml)
.and_return({
'project_tree' => [],
'methods' => {
'project' => %i[id title],
'notes' => %i[id]
},
'ee' => {
'project_tree' => [],
'methods' => {
'project' => %i[date],
'foo' => %i[bar baz]
}
}
})
expect(yaml_file.to_h).to eq({
'project_tree' => [],
'methods' => {
'project' => %i[id title date],
'notes' => %i[id],
'foo' => %i[bar baz]
}
})
end
end
end
end
|