jirarest2 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +18 -0
- data/Manifest.txt +6 -0
- data/bin/jira_create_issue +5 -5
- data/lib/jirarest2.rb +3 -1
- data/lib/jirarest2/connect.rb +12 -3
- data/lib/jirarest2/cookie_credentials.rb +4 -1
- data/lib/jirarest2/credentials.rb +4 -1
- data/lib/jirarest2/exceptions.rb +5 -0
- data/lib/jirarest2/field.rb +645 -0
- data/lib/jirarest2/issue.rb +7 -0
- data/lib/jirarest2/issuetype.rb +256 -0
- data/lib/jirarest2/madbitconfig.rb +3 -1
- data/lib/jirarest2/newissue.rb +30 -162
- data/lib/jirarest2/result.rb +1 -8
- data/lib/jirarest2/services.rb +1 -1
- data/lib/jirarest2/services/comment.rb +1 -0
- data/lib/jirarest2/services/issuelink.rb +1 -0
- data/lib/jirarest2bin.rb +2 -2
- data/test/data/createmeta +1 -0
- data/test/test_fieldcreatemeta.rb +820 -0
- data/test/test_fields.rb +395 -0
- data/test/test_issue.rb +4 -3
- data/test/test_issuetype.rb +74 -0
- data/test/test_newissue.rb +3 -4
- metadata +30 -46
- metadata.gz.sig +0 -0
data/test/test_fields.rb
ADDED
@@ -0,0 +1,395 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "jirarest2/field"
|
3
|
+
require "deb"
|
4
|
+
|
5
|
+
module Jirarest2Field
|
6
|
+
class TestField < MiniTest::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@fieldid ||= nil # Set to nil if not already set (avoid warnings)
|
9
|
+
@fieldid = "FieldID" if @fieldid.nil?
|
10
|
+
@fieldname ||= nil # Set to nil if not already set
|
11
|
+
@fieldname = "Fieldname" if @fieldname.nil?
|
12
|
+
@fieldargs ||= nil # Set to nil if not already set (avoid warnings)
|
13
|
+
@fieldargs = Hash.new if @fieldargs.nil?
|
14
|
+
@fieldrequired ||= nil # Set to nil if not already set (avoid warnings)
|
15
|
+
if @fieldrequired.nil? then
|
16
|
+
@fieldrequired = false
|
17
|
+
end
|
18
|
+
@fieldargs[:required] = @fieldrequired
|
19
|
+
@fieldtype ||= nil # Set to nil if not already set (avoid warnings)
|
20
|
+
@fieldtype = "Field" if @fieldtype.nil?
|
21
|
+
@field = eval(@fieldtype).new(@fieldid,@fieldname,@fieldargs)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_required
|
25
|
+
assert_equal @fieldrequired,@field.required
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_id
|
29
|
+
assert_equal @fieldid,@field.id
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_name
|
33
|
+
assert_equal @fieldname,@field.name
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_allowed
|
37
|
+
@field.allowed_values = ["one","two","three","four","mad cow","42"]
|
38
|
+
@field.value = "one"
|
39
|
+
@field.value = "mad cow"
|
40
|
+
assert_raises(Jirarest2::ValueNotAllowedException) { @field.value = 42 }
|
41
|
+
assert_raises(Jirarest2::ValueNotAllowedException) { @field.value = "five" }
|
42
|
+
end
|
43
|
+
end # class TestField
|
44
|
+
|
45
|
+
class TestTextField < TestField
|
46
|
+
def setup
|
47
|
+
@fieldid = "customfield_10101"
|
48
|
+
@fieldname = "issuetype"
|
49
|
+
@fieldtype = "TextField"
|
50
|
+
@fieldargs = Hash.new
|
51
|
+
@fieldrequired = true
|
52
|
+
super
|
53
|
+
end
|
54
|
+
|
55
|
+
# This could be put to the top class but here it is anchored
|
56
|
+
def test_fieldtype
|
57
|
+
assert_instance_of Jirarest2Field::TextField, @field
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_to_j
|
61
|
+
# ret = {"customfield_10101" => nil}
|
62
|
+
ret = nil
|
63
|
+
assert_equal ret,@field.to_j
|
64
|
+
@field.value = "Lorem ipsumus"
|
65
|
+
ret = {"customfield_10101"=>"Lorem ipsumus"}
|
66
|
+
assert_equal ret,@field.to_j
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_set_get_value
|
70
|
+
@field.value = "Lorem ipsum"
|
71
|
+
assert_equal "Lorem ipsum",@field.value
|
72
|
+
end
|
73
|
+
|
74
|
+
end # class TestTextField
|
75
|
+
|
76
|
+
class TestDateTimeField < TestField
|
77
|
+
def setup
|
78
|
+
@fieldid = "customfield_10001"
|
79
|
+
@fieldname = "Date Time Field"
|
80
|
+
@fieldtype = "DateTimeField"
|
81
|
+
@fieldargs = Hash.new
|
82
|
+
@fieldrequired = true
|
83
|
+
super
|
84
|
+
end
|
85
|
+
|
86
|
+
# This could be put to the top class but here it is anchored
|
87
|
+
def test_fieldtype
|
88
|
+
assert_instance_of Jirarest2Field::DateTimeField, @field
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_set_get_value
|
92
|
+
field_string = "2012-07-31 14:32:26.134"
|
93
|
+
fieldiso8601 = "2012-07-31T14:32:26+00:00"
|
94
|
+
@field.value = field_string
|
95
|
+
assert_equal fieldiso8601,@field.value
|
96
|
+
assert_equal DateTime.parse("2012-07-31T14:32:26.134+00:00"),@field.value(true)
|
97
|
+
@field.value = "12-07-31 14:32:26.134"
|
98
|
+
assert_equal fieldiso8601,@field.value
|
99
|
+
@field.value = "31.7.2012 14:32:26.134"
|
100
|
+
assert_equal fieldiso8601,@field.value
|
101
|
+
@field.value = "12-7-31 14:32:26.134"
|
102
|
+
assert_equal fieldiso8601,@field.value
|
103
|
+
@field.value = "14:32:26.134 31.07.2012"
|
104
|
+
assert_equal fieldiso8601,@field.value
|
105
|
+
assert_raises(ArgumentError) { @field.value = "7.31.2012 21:24:31" }
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_allowed
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_to_j
|
112
|
+
ret = nil
|
113
|
+
assert_equal ret,@field.to_j
|
114
|
+
@field.value = "2011-01-31 15:25:34"
|
115
|
+
ret = {"customfield_10001" => "2011-01-31T15:25:34.000+0000"}
|
116
|
+
assert_equal ret,@field.to_j
|
117
|
+
end
|
118
|
+
end # class TestDateTimeField
|
119
|
+
|
120
|
+
class TestNumberField < TestField
|
121
|
+
def setup
|
122
|
+
@fieldid = "timespent"
|
123
|
+
@fieldname = "Time Spent"
|
124
|
+
@fieldtype = "NumberField"
|
125
|
+
@fieldargs = Hash.new
|
126
|
+
@fieldrequired = false
|
127
|
+
super
|
128
|
+
end
|
129
|
+
|
130
|
+
# This could be put to the top class but here it is anchored
|
131
|
+
def test_fieldtype
|
132
|
+
assert_instance_of Jirarest2Field::NumberField, @field
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_allowed
|
136
|
+
@field.allowed_values = ["one","two","three","four","mad cow","42",13,23,99]
|
137
|
+
assert_raises(Jirarest2::ValueNotAllowedException) { @field.value = "one" }
|
138
|
+
assert_raises(Jirarest2::ValueNotAllowedException) { @field.value = "mad cow"}
|
139
|
+
assert_raises(Jirarest2::ValueNotAllowedException) { @field.value = 42 }
|
140
|
+
@field.value = "13"
|
141
|
+
assert_equal 13,@field.value
|
142
|
+
@field.value = 13
|
143
|
+
assert_equal 13,@field.value
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_set_get_value
|
147
|
+
@field.value = 12
|
148
|
+
assert_equal 12,@field.value
|
149
|
+
@field.value = 12.5
|
150
|
+
assert_equal 12.5,@field.value
|
151
|
+
@field.value = "12"
|
152
|
+
assert_equal 12,@field.value
|
153
|
+
@field.value = "12.5"
|
154
|
+
assert_equal 12.5,@field.value
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_to_j
|
158
|
+
assert_equal nil,@field.to_j
|
159
|
+
@field.value = "12.54"
|
160
|
+
ret = {"timespent" => 12.54}
|
161
|
+
assert_equal ret,@field.to_j
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
end # class TestNumberField
|
166
|
+
|
167
|
+
class TestHashField < TestField
|
168
|
+
def setup
|
169
|
+
@fieldid = "customfield_10006"
|
170
|
+
@fieldname = "List select"
|
171
|
+
@fieldtype = "HashField"
|
172
|
+
@fieldargs = Hash.new
|
173
|
+
@fieldrequired = true
|
174
|
+
@key = "value"
|
175
|
+
@field = HashField.new(@fieldid,@fieldname,{:key => @key, :required => @fieldrequired})
|
176
|
+
end
|
177
|
+
|
178
|
+
# This could be put to the top class but here it is anchored
|
179
|
+
def test_fieldtype
|
180
|
+
assert_instance_of Jirarest2Field::HashField, @field
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_set_get_value
|
184
|
+
@field.value = "Lorem ipsum"
|
185
|
+
assert_equal "Lorem ipsum",@field.value
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_to_j
|
189
|
+
ret = nil
|
190
|
+
assert_equal ret, @field.to_j
|
191
|
+
field = Jirarest2Field::HashField.new("blah","mumbatz",{:key => "name"})
|
192
|
+
field.value = "test"
|
193
|
+
ret = {"blah"=>{"name" => "test"}}
|
194
|
+
assert_equal ret, field.to_j
|
195
|
+
field = Jirarest2Field::HashField.new("badfield","mineme",{:key => "key", :required => true})
|
196
|
+
field.value = "MFTP"
|
197
|
+
ret = {"badfield"=>{"key" => "MFTP"}}
|
198
|
+
assert_equal ret, field.to_j
|
199
|
+
field = Jirarest2Field::HashField.new("idfield","minime",{:key => "id", :required => false})
|
200
|
+
field.value = "SP"
|
201
|
+
ret = {"idfield"=>{"id" => "SP"}}
|
202
|
+
assert_equal ret, field.to_j
|
203
|
+
end
|
204
|
+
|
205
|
+
end # class TestHashField
|
206
|
+
|
207
|
+
class TestMultiField < TestField
|
208
|
+
def setup
|
209
|
+
@fieldid = "customfield_10006"
|
210
|
+
@fieldname = "List select"
|
211
|
+
@fieldtype = "MultiField"
|
212
|
+
@fieldargs = Hash.new
|
213
|
+
@fieldrequired = false
|
214
|
+
super
|
215
|
+
end
|
216
|
+
|
217
|
+
# This could be put to the top class but here it is anchored
|
218
|
+
def test_fieldtype
|
219
|
+
assert_instance_of Jirarest2Field::MultiField, @field
|
220
|
+
end
|
221
|
+
|
222
|
+
def test_allowed_set
|
223
|
+
@field.allowed_values = ["one","two","three","four","mad cow","42"]
|
224
|
+
@field.value = "one"
|
225
|
+
assert_equal ["one"],@field.value
|
226
|
+
@field.value = "mad cow"
|
227
|
+
assert_equal ["mad cow"],@field.value
|
228
|
+
@field.value = ["one","three","42"]
|
229
|
+
assert_equal ["one","three","42"],@field.value
|
230
|
+
assert_raises(Jirarest2::ValueNotAllowedException) { @field.value = ["one","five","42"] }
|
231
|
+
assert_raises(Jirarest2::ValueNotAllowedException) { @field.value = ["one","two",42] }
|
232
|
+
assert_raises(Jirarest2::ValueNotAllowedException) { @field.value = 42 }
|
233
|
+
assert_raises(Jirarest2::ValueNotAllowedException) { @field.value = "five" }
|
234
|
+
end
|
235
|
+
|
236
|
+
def test_allowed_push
|
237
|
+
@field.allowed_values = ["one","two","three","four","mad cow","42",55,42,35,88,67]
|
238
|
+
@field.value = [55,42,35,88]
|
239
|
+
assert_raises(Jirarest2::ValueNotAllowedException) { @field[1] = "42" }
|
240
|
+
assert_raises(Jirarest2::ValueNotAllowedException) { @field[1] = 23 }
|
241
|
+
@field[1] = 67
|
242
|
+
assert_equal [55, 67, 35, 88],@field.value
|
243
|
+
end
|
244
|
+
|
245
|
+
def test_set_get_value
|
246
|
+
@field.value = "Lorem ipsum"
|
247
|
+
assert_equal ["Lorem ipsum"],@field.value
|
248
|
+
test = ["number1","number2"]
|
249
|
+
@field.value = test
|
250
|
+
assert_equal test,@field.value
|
251
|
+
test = [HashField.new("bugger","Big Bugger",{:key => "name"}),HashField.new("snigger","Snigger",{:key => "name"})]
|
252
|
+
@field.value = test
|
253
|
+
assert_equal test,@field.value
|
254
|
+
end
|
255
|
+
|
256
|
+
def test_delete
|
257
|
+
@field.value = ["ene","mine","mo","minki","pinki","poo"]
|
258
|
+
@field.delete("mo")
|
259
|
+
assert_equal ["ene","mine","minki","pinki","poo"],@field.value
|
260
|
+
@field.delete(@field)
|
261
|
+
assert_equal [],@field.value
|
262
|
+
end
|
263
|
+
def setup_an_array
|
264
|
+
h1 = HashField.new("custom42","Big Bugger",{:key => "name"})
|
265
|
+
h2 = HashField.new("custom44","Snigger",{:key => "name"})
|
266
|
+
h3 = HashField.new("custom10056","Bloop",{:key => "id"})
|
267
|
+
h4 = HashField.new("custom66","snoop",{:key => "id"})
|
268
|
+
h1.value = "me"
|
269
|
+
h2.value = "minime"
|
270
|
+
h3.value = "me"
|
271
|
+
h4.value = "moooo"
|
272
|
+
@test = [h1,h2,h3,h4]
|
273
|
+
@field.value = [h1,h2,h3,h4]
|
274
|
+
end
|
275
|
+
|
276
|
+
def test_delete_by_value
|
277
|
+
setup_an_array
|
278
|
+
h1 = @test[0]
|
279
|
+
h3 = @test[2]
|
280
|
+
h4 = @test[3]
|
281
|
+
assert_equal [h1,h3,h4],@field.delete_by_value("minime")
|
282
|
+
assert_equal [h1,h3,h4],@field.value
|
283
|
+
assert_equal [h4],@field.delete_by_value("me")
|
284
|
+
assert_equal [h4],@field.value
|
285
|
+
end
|
286
|
+
|
287
|
+
def test_index_get
|
288
|
+
setup_an_array
|
289
|
+
val = @test[2]
|
290
|
+
assert_equal val,@field[2]
|
291
|
+
end
|
292
|
+
|
293
|
+
def test_index_set
|
294
|
+
setup_an_array
|
295
|
+
val = HashField.new("snigger","Snigger",{:key => "name"})
|
296
|
+
@field[3] = val
|
297
|
+
assert_equal val,@field.value[3]
|
298
|
+
val1 = "a String"
|
299
|
+
assert_raises(Jirarest2::ValueNotAllowedException) { @field[6] = val1 } # No field mixing allowed
|
300
|
+
end
|
301
|
+
|
302
|
+
def test_push
|
303
|
+
@field << "Mikey"
|
304
|
+
@field << "Minney"
|
305
|
+
assert_raises(Jirarest2::ValueNotAllowedException) { @field << 42 }
|
306
|
+
assert_equal ["Mikey", "Minney"],@field.value
|
307
|
+
end
|
308
|
+
|
309
|
+
def test_to_j
|
310
|
+
ret = nil
|
311
|
+
assert_equal ret, @field.to_j
|
312
|
+
setup_an_array
|
313
|
+
ret = {"customfield_10006"=>[{"name"=>"me"}, {"name"=>"minime"}, {"id"=>"me"}, {"id"=>"moooo"}]}
|
314
|
+
assert_equal ret, @field.to_j
|
315
|
+
@field.value = ["number1","number2","number3"]
|
316
|
+
ret = {"customfield_10006"=>["number1", "number2", "number3"]}
|
317
|
+
assert_equal ret, @field.to_j
|
318
|
+
|
319
|
+
end
|
320
|
+
end # class TestMultiField
|
321
|
+
|
322
|
+
class TestCascadingField < TestField
|
323
|
+
def setup
|
324
|
+
@fieldid = "customfield_10000"
|
325
|
+
@fieldname = "Cascading Select Test"
|
326
|
+
@fieldtype = "CascadingField"
|
327
|
+
@fieldargs = Hash.new
|
328
|
+
@fieldrequired = true
|
329
|
+
super
|
330
|
+
end
|
331
|
+
|
332
|
+
# This could be put to the top class but here it is anchored
|
333
|
+
def test_fieldtype
|
334
|
+
assert_instance_of Jirarest2Field::CascadingField, @field
|
335
|
+
end
|
336
|
+
|
337
|
+
def test_to_j
|
338
|
+
ret = nil
|
339
|
+
assert_equal ret,@field.to_j
|
340
|
+
end
|
341
|
+
|
342
|
+
def test_set_get_value
|
343
|
+
assert_raises(Jirarest2::ValueNotAllowedException) { @field.value = "Lorem ipsum" }
|
344
|
+
@field.value = ["Lorem","ipsum"]
|
345
|
+
assert_equal ["Lorem", "ipsum"],@field.value
|
346
|
+
end
|
347
|
+
|
348
|
+
def test_allowed
|
349
|
+
@field.allowed_values= [{ "color" => ["red","green","yellow"],"car" => ["bmw","mini","mg","vw"], "lang" => ["ruby","Java","C","C#"]}]
|
350
|
+
@field.value = ["color","red"]
|
351
|
+
@field.value = ["car","mg"]
|
352
|
+
assert_raises(Jirarest2::ValueNotAllowedException) { @field.value = ["color","lang"] }
|
353
|
+
assert_raises(Jirarest2::ValueNotAllowedException) { @field.value = ["color"] }
|
354
|
+
assert_raises(Jirarest2::ValueNotAllowedException) { @field.value = ["music"] }
|
355
|
+
assert_raises(Jirarest2::ValueNotAllowedException) { @field.value = ["music","Cello"] }
|
356
|
+
end
|
357
|
+
|
358
|
+
end # class TestCascadingField
|
359
|
+
|
360
|
+
end # module
|
361
|
+
|
362
|
+
=begin
|
363
|
+
Shouldn't be used again. Is kept here just in case
|
364
|
+
def get_createmeta
|
365
|
+
require "json"
|
366
|
+
j = JSON.parse( IO.read("data/createmeta"))
|
367
|
+
string = "# -*- coding: utf-8 -*-\n"
|
368
|
+
string << "require \"minitest/autorun\"\n"
|
369
|
+
string << "require \"jirarest2/field\"\n"
|
370
|
+
string << "require \"json\"\n"
|
371
|
+
string << "require \"deb\"\n\n"
|
372
|
+
string << "# Extraclass to get all the different cases\n"
|
373
|
+
string << "class TestFieldCreatemeta < MiniTest::Unit::TestCase\n\n"
|
374
|
+
string << "=begin\n"
|
375
|
+
j["projects"][0]["issuetypes"][0]["fields"].each{ |id,cont|
|
376
|
+
string << " def test_#{id}\n"
|
377
|
+
string << " fstruct = \{\"#{id}\" => #{cont}\}\n"
|
378
|
+
string << " ppp fstruct\n"
|
379
|
+
string << " field = Jirarest2Field::TODO.new(\"#{id}\",\"#{cont["name"]}\",{:required => false, :createmeta => fstruct[\"#{id}\"]})\n"
|
380
|
+
string << " ppp field\n"
|
381
|
+
string << " allowed_v = [] # TODO \n"
|
382
|
+
string << " assert_equal \"#{id}\", field.id\n"
|
383
|
+
string << " assert_equal \"#{cont["name"]}\", field.name\n"
|
384
|
+
string << " assert_equal false, field.readonly\n"
|
385
|
+
string << " assert_equal \"value\", field.key\n"
|
386
|
+
string << " assert_raises(NoMethodError) { field.key }\n"
|
387
|
+
string << " assert_equal allowed_v, field.allowed_values\n"
|
388
|
+
string << " end\n\n"
|
389
|
+
}
|
390
|
+
string << "=end\n"
|
391
|
+
string << "end"
|
392
|
+
File.open("test_fieldcreatemeta.rb", 'w') {|f| f.write(string) }
|
393
|
+
end
|
394
|
+
=end
|
395
|
+
|
data/test/test_issue.rb
CHANGED
@@ -19,9 +19,10 @@ class TestIssue < MiniTest::Unit::TestCase
|
|
19
19
|
|
20
20
|
def test_receive
|
21
21
|
issue = Issue.new("SP-2")
|
22
|
-
|
23
|
-
#
|
24
|
-
|
22
|
+
# @todo write tests
|
23
|
+
# WebMock.disable!
|
24
|
+
# ppp issue.receive(@con)
|
25
|
+
# WebMock.enable!
|
25
26
|
end
|
26
27
|
|
27
28
|
def test_set_assignee_no_rights
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "jirarest2/issuetype"
|
3
|
+
require "json"
|
4
|
+
require "deb"
|
5
|
+
|
6
|
+
class TestIssuetype < MiniTest::Unit::TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@createmeta = JSON.parse(IO.read(File.dirname(__FILE__) + "/data/createmeta"))
|
10
|
+
@issue = Issuetype.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_createmeta
|
14
|
+
#ppp @createmeta
|
15
|
+
# ppp @createmeta["projects"][0]["issuetypes"][0]
|
16
|
+
@issue.createmeta(@createmeta["projects"][0]["issuetypes"][0])
|
17
|
+
assert_equal "My issue type", @issue.name
|
18
|
+
assert_equal "An own issue type",@issue.description
|
19
|
+
assert_equal "summary",@issue.required_fields[0].id
|
20
|
+
assert_equal "issuetype",@issue.required_fields[1].id
|
21
|
+
assert_equal "reporter",@issue.required_fields[2].id
|
22
|
+
assert_equal "project",@issue.required_fields[3].id
|
23
|
+
assert_equal 4, @issue.required_fields.size
|
24
|
+
assert_equal 44, @issue.fields.size
|
25
|
+
# Some order as in test_fieldcreatemeta.rb
|
26
|
+
fieldtypes = ["TextField", "TextField", "TimetrackingField", "VersionField", "TextField", "MultiVersionField", "HashField", "MultiUserField", "NumberField", "TextField", "ProjectField", "HashField", "MultiVersionField", "UserField", "TextField", "HashField", "DateTimeField", "DateField", "DateField", "TextField", "TextField", "NumberField", "MultiHashField", "NumberField", "CascadingField", "TextField", "TextField", "TextField", "HashField", "MultiHashField", "MultiStringField", "UserField", "UserField", "UserField", "HashField", "HashField", "MultiStringField", "MultiUserField", "ProjectField", "MultiVersionField", "TextField", "UserField", "NumberField", "MultiHashField"]
|
27
|
+
(0..@issue.fields.size-1).each{ |i|
|
28
|
+
assert_equal "Jirarest2Field::"+fieldtypes[i], @issue.fields.values[i].class.to_s
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_set_value
|
33
|
+
@issue.createmeta(@createmeta["projects"][0]["issuetypes"][0])
|
34
|
+
@issue.set_value("summary","blablabla")
|
35
|
+
assert_equal "blablabla", @issue.fields["summary"].value
|
36
|
+
@issue.set_value("Summary","blablabla1")
|
37
|
+
assert_equal "blablabla1", @issue.fields["summary"].value
|
38
|
+
@issue.set_value("summary","blablabla2",:id)
|
39
|
+
assert_equal "blablabla2", @issue.fields["summary"].value
|
40
|
+
@issue.set_value("Summary","blablabla3",:name)
|
41
|
+
assert_equal "blablabla3", @issue.fields["summary"].value
|
42
|
+
assert_raises(Jirarest2::WrongFieldnameException) { @issue.set_value("summary-wrong","blablabla") }
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_get_value
|
46
|
+
@issue.createmeta(@createmeta["projects"][0]["issuetypes"][0])
|
47
|
+
@issue.fields["summary"].value = "blues"
|
48
|
+
assert_equal "blues", @issue.get_value("Summary")
|
49
|
+
assert_equal "blues", @issue.get_value("summary")
|
50
|
+
assert_equal "blues", @issue.get_value("Summary",:name)
|
51
|
+
assert_equal "blues", @issue.get_value("summary",:id)
|
52
|
+
assert_raises(Jirarest2::WrongFieldnameException) { @issue.get_value("summary-wrong") }
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_required_by_name
|
56
|
+
@issue.createmeta(@createmeta["projects"][0]["issuetypes"][0])
|
57
|
+
assert_equal ["Summary"], @issue.required_by_name(true)
|
58
|
+
@issue.fields["summary"].value = "Let us fill it with something usefull"
|
59
|
+
assert_equal ["Summary"], @issue.required_by_name
|
60
|
+
assert_equal [], @issue.required_by_name(true)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_new_ticket_hash
|
64
|
+
start = {"self"=>"http://localhost:2990/jira/rest/api/2/issuetype/6", "id" => "6", "description" => "An own issue type", "iconUrl" => "http://localhost:2990/jira/images/icons/ico_epic.png", "name" => "My issue type", "subtask" => false, "expand" => "fields", "fields" => {"summary" => {"required"=>true, "schema"=>{"type" => "string", "system" => "summary"}, "name" => "Summary", "operations" => ["set"]}, "customfield_10307" => {"required" => false, "schema" => {"type" => "string", "custom" => "com.atlassian.jira.plugin.system.customfieldtypes:url", "customId" => 10307}, "name" => "URL", "operations" => ["set"]}}}
|
65
|
+
@issue.createmeta(start)
|
66
|
+
@issue.createmeta(@createmeta["projects"][0]["issuetypes"][0])
|
67
|
+
@issue.fields["summary"].value = "Let us fill it with something usefull"
|
68
|
+
val = {"fields" => {"summary" => "Let us fill it with something usefull", "issuetype" => {"name" => "My issue type"}, "project" => {"key" => "MFTP"}}}
|
69
|
+
assert_equal val, @issue.new_ticket_hash
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end # class TestIssuetype
|
74
|
+
|