jira-ruby 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +7 -1
- data/Guardfile +1 -1
- data/Rakefile +4 -5
- data/http-basic-example.rb +13 -12
- data/jira-ruby.gemspec +9 -10
- data/lib/jira-ruby.rb +5 -2
- data/lib/jira/base.rb +49 -48
- data/lib/jira/base_factory.rb +1 -4
- data/lib/jira/client.rb +29 -20
- data/lib/jira/has_many_proxy.rb +0 -1
- data/lib/jira/http_client.rb +9 -10
- data/lib/jira/http_error.rb +3 -5
- data/lib/jira/oauth_client.rb +19 -20
- data/lib/jira/request_client.rb +3 -4
- data/lib/jira/resource/agile.rb +10 -8
- data/lib/jira/resource/applinks.rb +5 -8
- data/lib/jira/resource/attachment.rb +1 -2
- data/lib/jira/resource/board.rb +84 -0
- data/lib/jira/resource/comment.rb +0 -2
- data/lib/jira/resource/component.rb +1 -3
- data/lib/jira/resource/createmeta.rb +12 -14
- data/lib/jira/resource/field.rb +22 -22
- data/lib/jira/resource/filter.rb +2 -2
- data/lib/jira/resource/issue.rb +41 -39
- data/lib/jira/resource/issuelink.rb +3 -5
- data/lib/jira/resource/issuelinktype.rb +0 -1
- data/lib/jira/resource/issuetype.rb +1 -3
- data/lib/jira/resource/priority.rb +1 -3
- data/lib/jira/resource/project.rb +5 -7
- data/lib/jira/resource/rapidview.rb +28 -7
- data/lib/jira/resource/remotelink.rb +1 -4
- data/lib/jira/resource/resolution.rb +2 -4
- data/lib/jira/resource/serverinfo.rb +1 -2
- data/lib/jira/resource/sprint.rb +82 -18
- data/lib/jira/resource/sprint_report.rb +8 -0
- data/lib/jira/resource/status.rb +1 -3
- data/lib/jira/resource/transition.rb +2 -6
- data/lib/jira/resource/user.rb +12 -2
- data/lib/jira/resource/version.rb +1 -3
- data/lib/jira/resource/watcher.rb +1 -5
- data/lib/jira/resource/webhook.rb +3 -6
- data/lib/jira/resource/worklog.rb +3 -5
- data/lib/jira/version.rb +1 -1
- data/lib/tasks/generate.rake +4 -4
- data/spec/integration/attachment_spec.rb +15 -16
- data/spec/integration/comment_spec.rb +31 -34
- data/spec/integration/component_spec.rb +21 -24
- data/spec/integration/field_spec.rb +15 -18
- data/spec/integration/issue_spec.rb +44 -48
- data/spec/integration/issuelinktype_spec.rb +8 -11
- data/spec/integration/issuetype_spec.rb +5 -7
- data/spec/integration/priority_spec.rb +5 -8
- data/spec/integration/project_spec.rb +13 -20
- data/spec/integration/rapidview_spec.rb +17 -10
- data/spec/integration/resolution_spec.rb +7 -10
- data/spec/integration/status_spec.rb +5 -8
- data/spec/integration/transition_spec.rb +17 -20
- data/spec/integration/user_spec.rb +24 -8
- data/spec/integration/version_spec.rb +21 -25
- data/spec/integration/watcher_spec.rb +28 -34
- data/spec/integration/webhook.rb +8 -17
- data/spec/integration/worklog_spec.rb +30 -34
- data/spec/jira/base_factory_spec.rb +11 -12
- data/spec/jira/base_spec.rb +204 -228
- data/spec/jira/client_spec.rb +26 -28
- data/spec/jira/has_many_proxy_spec.rb +11 -12
- data/spec/jira/http_client_spec.rb +51 -52
- data/spec/jira/http_error_spec.rb +7 -9
- data/spec/jira/oauth_client_spec.rb +44 -46
- data/spec/jira/request_client_spec.rb +5 -5
- data/spec/jira/resource/agile_spec.rb +5 -7
- data/spec/jira/resource/attachment_spec.rb +25 -26
- data/spec/jira/resource/board_spec.rb +175 -0
- data/spec/jira/resource/createmeta_spec.rb +29 -32
- data/spec/jira/resource/field_spec.rb +42 -48
- data/spec/jira/resource/filter_spec.rb +40 -40
- data/spec/jira/resource/issue_spec.rb +87 -89
- data/spec/jira/resource/issuelink_spec.rb +1 -1
- data/spec/jira/resource/project_factory_spec.rb +2 -4
- data/spec/jira/resource/project_spec.rb +33 -33
- data/spec/jira/resource/sprint_spec.rb +78 -0
- data/spec/jira/resource/user_factory_spec.rb +6 -8
- data/spec/jira/resource/worklog_spec.rb +9 -11
- data/spec/spec_helper.rb +8 -9
- data/spec/support/clients_helper.rb +4 -4
- data/spec/support/shared_examples/integration.rb +60 -77
- metadata +59 -53
@@ -1,21 +1,21 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe JIRA::Resource::Createmeta do
|
4
|
-
let(:client)
|
4
|
+
let(:client) do
|
5
5
|
double(
|
6
6
|
'client',
|
7
|
-
:
|
8
|
-
:
|
7
|
+
options: {
|
8
|
+
rest_base_path: '/jira/rest/api/2'
|
9
9
|
}
|
10
10
|
)
|
11
|
-
|
11
|
+
end
|
12
12
|
|
13
|
-
let(:response)
|
13
|
+
let(:response) do
|
14
14
|
double(
|
15
15
|
'response',
|
16
|
-
:
|
16
|
+
body: '{"expand":"projects","projects":[{"self":"http://localhost:2029/rest/api/2/project/TST","id":"10200","key":"test_key","name":"Test Name"}]}'
|
17
17
|
)
|
18
|
-
|
18
|
+
end
|
19
19
|
|
20
20
|
describe 'general' do
|
21
21
|
it 'should query correct url without parameters' do
|
@@ -25,12 +25,12 @@ describe JIRA::Resource::Createmeta do
|
|
25
25
|
|
26
26
|
it 'should query correct url with `expand` parameter' do
|
27
27
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?expand=projects.issuetypes.fields').and_return(response)
|
28
|
-
JIRA::Resource::Createmeta.all(client, :
|
28
|
+
JIRA::Resource::Createmeta.all(client, expand: 'projects.issuetypes.fields')
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should query correct url with `foo` parameter' do
|
32
32
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?foo=bar').and_return(response)
|
33
|
-
JIRA::Resource::Createmeta.all(client, :
|
33
|
+
JIRA::Resource::Createmeta.all(client, foo: 'bar')
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should return an array of createmeta objects' do
|
@@ -49,7 +49,7 @@ describe JIRA::Resource::Createmeta do
|
|
49
49
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectKeys=PROJECT_1').and_return(response)
|
50
50
|
JIRA::Resource::Createmeta.all(
|
51
51
|
client,
|
52
|
-
:
|
52
|
+
projectKeys: 'PROJECT_1'
|
53
53
|
)
|
54
54
|
end
|
55
55
|
|
@@ -57,7 +57,7 @@ describe JIRA::Resource::Createmeta do
|
|
57
57
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectKeys=PROJECT_1%2CPROJECT_2').and_return(response)
|
58
58
|
JIRA::Resource::Createmeta.all(
|
59
59
|
client,
|
60
|
-
:
|
60
|
+
projectKeys: %w[PROJECT_1 PROJECT_2]
|
61
61
|
)
|
62
62
|
end
|
63
63
|
|
@@ -68,7 +68,7 @@ describe JIRA::Resource::Createmeta do
|
|
68
68
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectKeys=PRJ').and_return(response)
|
69
69
|
JIRA::Resource::Createmeta.all(
|
70
70
|
client,
|
71
|
-
:
|
71
|
+
projectKeys: prj
|
72
72
|
)
|
73
73
|
end
|
74
74
|
|
@@ -81,7 +81,7 @@ describe JIRA::Resource::Createmeta do
|
|
81
81
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectKeys=PRJ_2%2CPRJ_1').and_return(response)
|
82
82
|
JIRA::Resource::Createmeta.all(
|
83
83
|
client,
|
84
|
-
:
|
84
|
+
projectKeys: [prj_2, prj_1]
|
85
85
|
)
|
86
86
|
end
|
87
87
|
|
@@ -92,18 +92,17 @@ describe JIRA::Resource::Createmeta do
|
|
92
92
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectKeys=PROJECT_1%2CPRJ_5').and_return(response)
|
93
93
|
JIRA::Resource::Createmeta.all(
|
94
94
|
client,
|
95
|
-
:
|
95
|
+
projectKeys: ['PROJECT_1', prj_5]
|
96
96
|
)
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
|
101
100
|
describe 'projectIds' do
|
102
101
|
it 'should query correct url when only one `projectIds` given as string' do
|
103
102
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectIds=10101').and_return(response)
|
104
103
|
JIRA::Resource::Createmeta.all(
|
105
104
|
client,
|
106
|
-
:
|
105
|
+
projectIds: '10101'
|
107
106
|
)
|
108
107
|
end
|
109
108
|
|
@@ -111,7 +110,7 @@ describe JIRA::Resource::Createmeta do
|
|
111
110
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectIds=10101%2C20202').and_return(response)
|
112
111
|
JIRA::Resource::Createmeta.all(
|
113
112
|
client,
|
114
|
-
:
|
113
|
+
projectIds: %w[10101 20202]
|
115
114
|
)
|
116
115
|
end
|
117
116
|
|
@@ -122,7 +121,7 @@ describe JIRA::Resource::Createmeta do
|
|
122
121
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectIds=30303').and_return(response)
|
123
122
|
JIRA::Resource::Createmeta.all(
|
124
123
|
client,
|
125
|
-
:
|
124
|
+
projectIds: prj
|
126
125
|
)
|
127
126
|
end
|
128
127
|
|
@@ -135,7 +134,7 @@ describe JIRA::Resource::Createmeta do
|
|
135
134
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectIds=50505%2C30303').and_return(response)
|
136
135
|
JIRA::Resource::Createmeta.all(
|
137
136
|
client,
|
138
|
-
:
|
137
|
+
projectIds: [prj_2, prj_1]
|
139
138
|
)
|
140
139
|
end
|
141
140
|
|
@@ -146,18 +145,17 @@ describe JIRA::Resource::Createmeta do
|
|
146
145
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectIds=10101%2C60606').and_return(response)
|
147
146
|
JIRA::Resource::Createmeta.all(
|
148
147
|
client,
|
149
|
-
:
|
148
|
+
projectIds: ['10101', prj_5]
|
150
149
|
)
|
151
150
|
end
|
152
151
|
end
|
153
152
|
|
154
|
-
|
155
153
|
describe 'issuetypeNames' do
|
156
154
|
it 'should query correct url when only one `issuetypeNames` given as string' do
|
157
155
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeNames=Feature').and_return(response)
|
158
156
|
JIRA::Resource::Createmeta.all(
|
159
157
|
client,
|
160
|
-
:
|
158
|
+
issuetypeNames: 'Feature'
|
161
159
|
)
|
162
160
|
end
|
163
161
|
|
@@ -165,7 +163,7 @@ describe JIRA::Resource::Createmeta do
|
|
165
163
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeNames=Feature%2CBug').and_return(response)
|
166
164
|
JIRA::Resource::Createmeta.all(
|
167
165
|
client,
|
168
|
-
:
|
166
|
+
issuetypeNames: %w[Feature Bug]
|
169
167
|
)
|
170
168
|
end
|
171
169
|
|
@@ -176,7 +174,7 @@ describe JIRA::Resource::Createmeta do
|
|
176
174
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeNames=Epic').and_return(response)
|
177
175
|
JIRA::Resource::Createmeta.all(
|
178
176
|
client,
|
179
|
-
:
|
177
|
+
issuetypeNames: issue_type
|
180
178
|
)
|
181
179
|
end
|
182
180
|
|
@@ -189,7 +187,7 @@ describe JIRA::Resource::Createmeta do
|
|
189
187
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeNames=Sub-Task%2CEpic').and_return(response)
|
190
188
|
JIRA::Resource::Createmeta.all(
|
191
189
|
client,
|
192
|
-
:
|
190
|
+
issuetypeNames: [issue_type_2, issue_type_1]
|
193
191
|
)
|
194
192
|
end
|
195
193
|
|
@@ -200,18 +198,17 @@ describe JIRA::Resource::Createmeta do
|
|
200
198
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeNames=Feature%2CEpic').and_return(response)
|
201
199
|
JIRA::Resource::Createmeta.all(
|
202
200
|
client,
|
203
|
-
:
|
201
|
+
issuetypeNames: ['Feature', issue_type]
|
204
202
|
)
|
205
203
|
end
|
206
204
|
end
|
207
205
|
|
208
|
-
|
209
206
|
describe 'issuetypeIds' do
|
210
207
|
it 'should query correct url when only one `issuetypeIds` given as string' do
|
211
208
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeIds=10101').and_return(response)
|
212
209
|
JIRA::Resource::Createmeta.all(
|
213
210
|
client,
|
214
|
-
:
|
211
|
+
issuetypeIds: '10101'
|
215
212
|
)
|
216
213
|
end
|
217
214
|
|
@@ -219,7 +216,7 @@ describe JIRA::Resource::Createmeta do
|
|
219
216
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeIds=10101%2C20202').and_return(response)
|
220
217
|
JIRA::Resource::Createmeta.all(
|
221
218
|
client,
|
222
|
-
:
|
219
|
+
issuetypeIds: %w[10101 20202]
|
223
220
|
)
|
224
221
|
end
|
225
222
|
|
@@ -230,7 +227,7 @@ describe JIRA::Resource::Createmeta do
|
|
230
227
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeIds=30303').and_return(response)
|
231
228
|
JIRA::Resource::Createmeta.all(
|
232
229
|
client,
|
233
|
-
:
|
230
|
+
issuetypeIds: issue_type
|
234
231
|
)
|
235
232
|
end
|
236
233
|
|
@@ -243,7 +240,7 @@ describe JIRA::Resource::Createmeta do
|
|
243
240
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeIds=50505%2C30303').and_return(response)
|
244
241
|
JIRA::Resource::Createmeta.all(
|
245
242
|
client,
|
246
|
-
:
|
243
|
+
issuetypeIds: [issue_type_2, issue_type_1]
|
247
244
|
)
|
248
245
|
end
|
249
246
|
|
@@ -254,7 +251,7 @@ describe JIRA::Resource::Createmeta do
|
|
254
251
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeIds=10101%2C30303').and_return(response)
|
255
252
|
JIRA::Resource::Createmeta.all(
|
256
253
|
client,
|
257
|
-
:
|
254
|
+
issuetypeIds: ['10101', issue_type]
|
258
255
|
)
|
259
256
|
end
|
260
257
|
end
|
@@ -1,91 +1,85 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe JIRA::Resource::Field do
|
4
|
-
|
5
4
|
let(:cache) { OpenStruct.new }
|
6
5
|
|
7
6
|
let(:client) do
|
8
|
-
client = double(options: {rest_base_path: '/jira/rest/api/2'}
|
7
|
+
client = double(options: { rest_base_path: '/jira/rest/api/2' })
|
9
8
|
field = JIRA::Resource::FieldFactory.new(client)
|
10
9
|
allow(client).to receive(:Field).and_return(field)
|
11
10
|
allow(client).to receive(:cache).and_return(cache)
|
12
11
|
# info about all fields on the client
|
13
12
|
allow(client.Field).to receive(:all).and_return([
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
13
|
+
JIRA::Resource::Field.new(client, attrs: { 'id' => 'customfield_10666', 'name' => 'Priority', 'custom' => true, 'orderable' => true, 'navigable' => true, 'searchable' => true, 'clauseNames' => ['cf[10666]', 'Priority'], 'schema' => { 'type' => 'string', 'custom' => 'com.atlassian.jira.plugin.system.customfieldtypes:select', 'customId' => 10_666 } }),
|
14
|
+
JIRA::Resource::Field.new(client, attrs: { 'id' => 'issuekey', 'name' => 'Key', 'custom' => false, 'orderable' => false, 'navigable' => true, 'searchable' => false, 'clauseNames' => %w[id issue issuekey key] }),
|
15
|
+
JIRA::Resource::Field.new(client, attrs: { 'id' => 'priority', 'name' => 'Priority', 'custom' => false, 'orderable' => true, 'navigable' => true, 'searchable' => true, 'clauseNames' => ['priority'], 'schema' => { 'type' => 'priority', 'system' => 'priority' } }),
|
16
|
+
JIRA::Resource::Field.new(client, attrs: { 'id' => 'summary', 'name' => 'Summary', 'custom' => false, 'orderable' => true, 'navigable' => true, 'searchable' => true, 'clauseNames' => ['summary'], 'schema' => { 'type' => 'string', 'system' => 'summary' } }),
|
17
|
+
JIRA::Resource::Field.new(client, attrs: { 'id' => 'issuetype', 'name' => 'Issue Type', 'custom' => false, 'orderable' => true, 'navigable' => true, 'searchable' => true, 'clauseNames' => %w[issuetype type], 'schema' => { 'type' => 'issuetype', 'system' => 'issuetype' } }),
|
18
|
+
JIRA::Resource::Field.new(client, attrs: { 'id' => 'customfield_10111', 'name' => 'SingleWord', 'custom' => true, 'orderable' => true, 'navigable' => true, 'searchable' => true, 'clauseNames' => ['cf[10111]', 'SingleWord'], 'schema' => { 'type' => 'string', 'custom' => 'com.atlassian.jira.plugin.system.customfieldtypes:select', 'customId' => 10_111 } }),
|
19
|
+
JIRA::Resource::Field.new(client, attrs: { 'id' => 'customfield_10222', 'name' => 'Multi Word', 'custom' => true, 'orderable' => true, 'navigable' => true, 'searchable' => true, 'clauseNames' => ['cf[10222]', 'Multi Word'], 'schema' => { 'type' => 'string', 'custom' => 'com.atlassian.jira.plugin.system.customfieldtypes:select', 'customId' => 10_222 } }),
|
20
|
+
JIRA::Resource::Field.new(client, attrs: { 'id' => 'customfield_10333', 'name' => 'Why/N@t', 'custom' => true, 'orderable' => true, 'navigable' => true, 'searchable' => true, 'clauseNames' => ['cf[10333]', 'Why/N@t'], 'schema' => { 'type' => 'string', 'custom' => 'com.atlassian.jira.plugin.system.customfieldtypes:select', 'customId' => 10_333 } }),
|
21
|
+
JIRA::Resource::Field.new(client, attrs: { 'id' => 'customfield_10444', 'name' => 'SingleWord', 'custom' => true, 'orderable' => true, 'navigable' => true, 'searchable' => true, 'clauseNames' => ['cf[10444]', 'SingleWord'], 'schema' => { 'type' => 'string', 'custom' => 'com.atlassian.jira.plugin.system.customfieldtypes:select', 'customId' => 10_444 } })
|
22
|
+
])
|
24
23
|
client
|
25
24
|
end
|
26
25
|
|
27
|
-
describe
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
})
|
40
|
-
}
|
26
|
+
describe 'field_mappings' do
|
27
|
+
shared_context 'mapped or not' do
|
28
|
+
subject do
|
29
|
+
JIRA::Resource::Field.new(client, attrs: {
|
30
|
+
'priority' => 1,
|
31
|
+
'customfield_10111' => 'data_in_custom_field',
|
32
|
+
'customfield_10222' => 'multi word custom name',
|
33
|
+
'customfield_10333' => 'complex custom name',
|
34
|
+
'customfield_10444' => 'duplicated custom name',
|
35
|
+
'customfield_10666' => 'duplicate of a system name'
|
36
|
+
})
|
37
|
+
end
|
41
38
|
|
42
|
-
it
|
39
|
+
it 'can find a standard field by id' do
|
43
40
|
expect(subject.priority).to eq(1)
|
44
41
|
end
|
45
42
|
|
46
|
-
it
|
43
|
+
it 'can find a custom field by customfield_##### name' do
|
47
44
|
expect(subject.customfield_10111).to eq('data_in_custom_field')
|
48
45
|
end
|
49
46
|
|
50
|
-
it
|
51
|
-
expect{subject.name}.to raise_error(NoMethodError)
|
52
|
-
expect{subject.custom}.to raise_error(NoMethodError)
|
47
|
+
it 'is not confused by common attribute keys' do
|
48
|
+
expect { subject.name }.to raise_error(NoMethodError)
|
49
|
+
expect { subject.custom }.to raise_error(NoMethodError)
|
53
50
|
expect(subject.id).to eq(nil) # picks up ID from the parent -
|
54
51
|
end
|
55
52
|
end
|
56
53
|
|
57
|
-
context
|
54
|
+
context 'before fields are mapped' do
|
55
|
+
include_context 'mapped or not'
|
58
56
|
|
59
|
-
|
60
|
-
|
61
|
-
it "can find a standard field by id" do
|
57
|
+
it 'can find a standard field by id' do
|
62
58
|
expect(subject.priority).to eq(1)
|
63
59
|
end
|
64
60
|
|
65
|
-
it
|
66
|
-
expect{subject.Priority}.to raise_error(NoMethodError)
|
61
|
+
it 'cannot find a standard field by name before mapping' do
|
62
|
+
expect { subject.Priority }.to raise_error(NoMethodError)
|
67
63
|
end
|
68
64
|
|
69
|
-
it
|
65
|
+
it 'can find a custom field by customfield_##### name' do
|
70
66
|
expect(subject.customfield_10111).to eq('data_in_custom_field')
|
71
67
|
end
|
72
68
|
|
73
|
-
it
|
74
|
-
expect{subject.name}.to raise_error(NoMethodError)
|
75
|
-
expect{subject.custom}.to raise_error(NoMethodError)
|
69
|
+
it 'is not confused by common attribute keys and raises error' do
|
70
|
+
expect { subject.name }.to raise_error(NoMethodError)
|
71
|
+
expect { subject.custom }.to raise_error(NoMethodError)
|
76
72
|
expect(subject.id).to eq(nil) # picks up ID from the parent -
|
77
73
|
end
|
78
74
|
end
|
79
75
|
|
80
|
-
context
|
81
|
-
|
82
|
-
include_context "mapped or not"
|
76
|
+
context 'after fields are mapped' do
|
77
|
+
include_context 'mapped or not'
|
83
78
|
|
84
|
-
it
|
85
|
-
expect{client.Field.map_fields}.to output(/renaming as Priority_10666/).to_stderr
|
86
|
-
expect{client.Field.map_fields}.to output(/renaming as SingleWord_10444/).to_stderr
|
79
|
+
it 'warns of duplicate fields' do
|
80
|
+
expect { client.Field.map_fields }.to output(/renaming as Priority_10666/).to_stderr
|
81
|
+
expect { client.Field.map_fields }.to output(/renaming as SingleWord_10444/).to_stderr
|
87
82
|
end
|
88
|
-
|
89
83
|
end
|
90
84
|
end
|
91
85
|
end
|
@@ -2,48 +2,48 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe JIRA::Resource::Filter do
|
4
4
|
let(:client) do
|
5
|
-
client = double
|
5
|
+
client = double
|
6
6
|
allow(client).to receive(:Issue).and_return(JIRA::Resource::IssueFactory.new(self))
|
7
7
|
client
|
8
8
|
end
|
9
9
|
let(:collection_path) { '/rest/api/2/filter' }
|
10
10
|
let(:jira_user) do
|
11
11
|
{
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
12
|
+
self: 'https://localhost/rest/api/2/user?username=ljharb',
|
13
|
+
name: 'ljharb',
|
14
|
+
avatarUrls: {
|
15
15
|
'16x16' => 'https://localhost/secure/useravatar?size=small&ownerId=ljharb&avatarId=1',
|
16
16
|
'48x48' => 'https://localhost/secure/useravatar?ownerId=ljharb&avatarId=1'
|
17
17
|
},
|
18
|
-
:
|
19
|
-
:
|
18
|
+
displayName: 'Jordan Harband',
|
19
|
+
active: true
|
20
20
|
}
|
21
21
|
end
|
22
22
|
let(:filter_attrs) do
|
23
23
|
{
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
24
|
+
self: "https://localhost#{collection_path}/42",
|
25
|
+
id: 42,
|
26
|
+
name: 'Resolved Tickets',
|
27
|
+
description: '',
|
28
|
+
owner: jira_user,
|
29
|
+
jql: '"Git Repository" ~ jira-ruby AND status = Resolved',
|
30
|
+
viewUrl: 'https://localhost/secure/IssueNavigator.jspa?mode=hide&requestId=42',
|
31
|
+
searchUrl: 'https://localhost/rest/api/2/search?jql=%22Git+Repository%22+~+jira-ruby+AND+status+%3D+Resolved',
|
32
|
+
favourite: false,
|
33
|
+
sharePermissions: [
|
34
34
|
{
|
35
|
-
:
|
36
|
-
:
|
35
|
+
id: 123,
|
36
|
+
type: 'global'
|
37
37
|
}
|
38
38
|
],
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
39
|
+
subscriptions: {
|
40
|
+
size: 0,
|
41
|
+
items: []
|
42
42
|
}
|
43
43
|
}
|
44
44
|
end
|
45
45
|
let(:filter_response) do
|
46
|
-
response = double
|
46
|
+
response = double
|
47
47
|
allow(response).to receive(:body).and_return(filter_attrs.to_json)
|
48
48
|
response
|
49
49
|
end
|
@@ -54,40 +54,40 @@ describe JIRA::Resource::Filter do
|
|
54
54
|
end
|
55
55
|
let(:jql_issue) do
|
56
56
|
{
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
63
|
-
:
|
57
|
+
id: '663147',
|
58
|
+
self: 'https://localhost/rest/api/2/issue/663147',
|
59
|
+
key: 'JIRARUBY-2386',
|
60
|
+
fields: {
|
61
|
+
reporter: jira_user,
|
62
|
+
created: '2013-12-11T23:28:02.000+0000',
|
63
|
+
assignee: jira_user
|
64
64
|
}
|
65
65
|
}
|
66
66
|
end
|
67
67
|
let(:jql_attrs) do
|
68
68
|
{
|
69
|
-
:
|
70
|
-
:
|
71
|
-
:
|
72
|
-
:
|
69
|
+
startAt: 0,
|
70
|
+
maxResults: 50,
|
71
|
+
total: 2,
|
72
|
+
issues: [jql_issue]
|
73
73
|
}
|
74
74
|
end
|
75
75
|
let(:issue_jql_response) do
|
76
|
-
response = double
|
76
|
+
response = double
|
77
77
|
allow(response).to receive(:body).and_return(jql_attrs.to_json)
|
78
78
|
response
|
79
79
|
end
|
80
80
|
|
81
|
-
it
|
81
|
+
it 'can be found by ID' do
|
82
82
|
expect(JSON.parse(filter.attrs.to_json)).to eql(JSON.parse(filter_attrs.to_json))
|
83
83
|
end
|
84
84
|
|
85
|
-
it
|
85
|
+
it 'returns issues' do
|
86
86
|
expect(filter).to be_present
|
87
|
-
allow(client).to receive(:options).and_return(
|
88
|
-
expect(client).to receive(:get)
|
89
|
-
with("localhost/search?jql=#{CGI.escape(filter.jql)}")
|
90
|
-
and_return(issue_jql_response)
|
87
|
+
allow(client).to receive(:options).and_return(rest_base_path: 'localhost')
|
88
|
+
expect(client).to receive(:get)
|
89
|
+
.with("localhost/search?jql=#{CGI.escape(filter.jql)}")
|
90
|
+
.and_return(issue_jql_response)
|
91
91
|
issues = filter.issues
|
92
92
|
expect(issues).to be_an(Array)
|
93
93
|
expect(issues.size).to eql(1)
|