jirarest2 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
@@ -1,2 +1 @@
1
- 4��$��Q�$EB�5Ή5��M�`�K�K�i�{�^o�T���]@�a������f�0�8�bV�����Q���3��h^�9"HX��!&��r6���3���fߐk@}p��4i�������p�Xg���=A
2
- g̾>�rs+Z뤘l�϶���S���[7���G1[�����Ui�- ť�bIP���뾶[���F��� �v�L��okІ�lO�F�����S�o�[|��>��n^�8��X
1
+ *s��!VQ񈫠�'�\3Y'1ݼ�bXi�T%T��s4���ι��A� �@h�������mhUO
@@ -1,3 +1,11 @@
1
+ === 0.0.15 / 2012-09-21
2
+
3
+ * 3 bug fixes:
4
+
5
+ * Changed the behaviour regarding custom fieldtypes with type "string". Those are now a TextField by default and only radiobuttons and select are named as exceptions
6
+ * Fixed a "bug" with jira versions that don't return the "issuetype" field in the createmeta statement
7
+ * Fixed the CascadingField type
8
+
1
9
  === 0.0.14 / 2012-09-19
2
10
 
3
11
  * 1 unknown:
@@ -18,7 +18,7 @@
18
18
  #
19
19
 
20
20
  # Version Parameter all CAPS
21
- VERSION = "0.0.14"
21
+ VERSION = "0.0.15"
22
22
  # Version Parameter
23
23
  Version = VERSION
24
24
 
@@ -418,6 +418,7 @@ protected
418
418
  end # class MultiField
419
419
 
420
420
  # The class to represent CascadingSelectFields
421
+ # @todo error message is more than just a bit misleading
421
422
  class CascadingField < Field
422
423
  # The key element for the answers - It should not be needed - but it's easer on the checks if it's exposed
423
424
  # @return [String] The key element for the way to Jira
@@ -434,6 +435,10 @@ protected
434
435
  # @return [Boolean] true if the value is allowed, false if not
435
436
  def value_allowed?(value)
436
437
  return true if @allowed_values == [] # If there is no list get out of here fast
438
+ # Special case to ensure that we can use the string "nil" if the is really an allowed value
439
+ if value[1] == "nil" && ( @allowed_values[0].has_key?(value[0]) && @allowed_values[0][value[0]] == [nil] ) then
440
+ value[1] = nil
441
+ end
437
442
  if @allowed_values[0].has_key?(value[0]) && @allowed_values[0][value[0]].include?(value[1]) then
438
443
  return true
439
444
  else
@@ -449,7 +454,7 @@ protected
449
454
  if ! content.instance_of?(Array) or content.size != 2 then
450
455
  raise Jirarest2::ValueNotAllowedException.new(@name,"Array"), "needs to be an Array with exactly 2 parameters. Was #{content.class}."
451
456
  end
452
- super
457
+ super(content)
453
458
  end
454
459
 
455
460
 
@@ -460,7 +465,11 @@ protected
460
465
  if @value.nil? then
461
466
  super(nil)
462
467
  else
463
- super({"value" => @value[0], "child" => {"value" => @value[1]}})
468
+ if @value[1].nil? then
469
+ super({"value" => @value[0]}) # If there is no child the server prefers not to be bothered
470
+ else
471
+ super({"value" => @value[0], "child" => {"value" => @value[1]}})
472
+ end
464
473
  end
465
474
  end
466
475
 
@@ -473,18 +482,23 @@ protected
473
482
 
474
483
  #Interpret the result of createmeta for one field
475
484
  # @attr [Hash](structure)
476
- # @note fills allowed_values with a straight list of allowed values
477
- # @todo Nothing is done here yet!
485
+ # @note fills allowed_values with a straight list of allowed values.
486
+ # @todo The implementation is awkward with only one element in the array and the fields as Hashes in element 0. See if this is should be rewritten.
478
487
  def createmeta(structure)
479
488
  @readonly = true if structure["operations"] == []
480
489
  @key = "value"
481
490
  if structure["allowedValues"] then
491
+ @allowed_values << Hash.new
482
492
  structure["allowedValues"].each{ |suggestion|
483
493
  subentries = Array.new
484
- suggestion["children"].each{ |entry|
485
- subentries << entry["value"]
486
- }
487
- @allowed_values << {suggestion[@key] => subentries}
494
+ if suggestion.has_key?("children") then
495
+ suggestion["children"].each{ |entry|
496
+ subentries << entry["value"]
497
+ }
498
+ else
499
+ subentries << nil
500
+ end
501
+ @allowed_values[0][suggestion[@key]] = subentries
488
502
  }
489
503
  end
490
504
  end
@@ -29,6 +29,7 @@ class Issuetype
29
29
  attr_reader :required_fields
30
30
 
31
31
  #Get the correct Fieldtype based on the schema from createmeta
32
+ # Strings are a little bit strange as the representation differs - some just go as values others go as hashes
32
33
  # @attr [Hash] schema The type description we get
33
34
  # @return [String] Name of the Fieldtype to use
34
35
  # @todo timetracking will probably not work
@@ -83,36 +84,25 @@ class Issuetype
83
84
  when /.*:cascadingselect$/
84
85
  return "CascadingField"
85
86
  else
86
- raise Jirarest2::CouldNotDetermineFieldtypeException schema
87
+ raise Jirarest2::CouldNotDetermineFieldtypeException, schema
87
88
  end
88
89
  else
89
- raise Jirarest2::CouldNotDetermineFieldtypeException schema
90
+ raise Jirarest2::CouldNotDetermineFieldtypeException, schema
90
91
  end
91
92
  when "string"
93
+ # Strings should be easy but unfortunately there are some strings that result in hashes
92
94
  return "TextField" if schema["system"]
93
- schema["custom"] =~ /.*:(\w*)$/
95
+ schema["custom"] =~ /.*:(\w*)$/
94
96
  case $1
95
- when "url"
96
- return "TextField"
97
- when "textfield"
98
- return "TextField"
99
- when "textarea"
100
- return "TextField"
101
97
  when "radiobuttons"
102
98
  return "HashField"
103
99
  when "select"
104
100
  return "HashField"
105
- when "hiddenjobswitch"
106
- return "TextField"
107
- when "readonlyfield"
108
- return "TextField"
109
- when "jobcheckbox"
110
- return "TextField"
111
101
  else
112
- raise Jirarest2::CouldNotDetermineFieldtypeException schema
102
+ return "TextField"
113
103
  end
114
104
  else
115
- raise Jirarest2::CouldNotDetermineFieldtypeException schema
105
+ raise Jirarest2::CouldNotDetermineFieldtypeException, schema
116
106
  end
117
107
 
118
108
  end # def decipher_schema
@@ -157,7 +147,7 @@ class Issuetype
157
147
  createmeta(json["editmeta"])
158
148
  else
159
149
  # We need to know what to fill and how
160
- raise Jirearesr2::FieldsUnknownError json["self"]
150
+ raise Jirearesr2::FieldsUnknownError, json["self"]
161
151
  end
162
152
  end
163
153
  @issuekey = json["key"]
@@ -210,6 +200,10 @@ class Issuetype
210
200
  @fields.each { |id,field|
211
201
  fields = fields.merge!(field.to_j) if ! field.to_j.nil? #Sending empty fields with a new ticket will not work
212
202
  }
203
+ # Work out some difference between different versions of JIRA(tm). Sometimes the issuetype is there as a field sometimes it isn't.
204
+ if !fields.has_key?("issuetype") then
205
+ fields["issuetype"] = {"name" => @name}
206
+ end
213
207
  h = {"fields" => fields}
214
208
  return h
215
209
  else
@@ -451,7 +451,7 @@ class TestFieldCreatemeta < MiniTest::Unit::TestCase
451
451
  def test_customfield_10000 # cascadingselect -> CascadingField
452
452
  fstruct = {"customfield_10000" => {"required"=>false, "schema"=>{"type"=>"array", "items"=>"string", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:cascadingselect", "customId"=>10000}, "name"=>"Cascading Select Test", "operations"=>["set"], "allowedValues"=>[{"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10000", "value"=>"English", "id"=>"10000", "children"=>[{"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10003", "value"=>"One", "id"=>"10003"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10004", "value"=>"Two", "id"=>"10004"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10005", "value"=>"Three", "id"=>"10005"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10006", "value"=>"Four", "id"=>"10006"}]}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10001", "value"=>"German", "id"=>"10001", "children"=>[{"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10007", "value"=>"Eins", "id"=>"10007"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10008", "value"=>"zwei", "id"=>"10008"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10009", "value"=>"drEi", "id"=>"10009"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10010", "value"=>"vier", "id"=>"10010"}]}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10002", "value"=>"ISO", "id"=>"10002", "children"=>[{"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10011", "value"=>"Unaone", "id"=>"10011"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10012", "value"=>"Bissotwo", "id"=>"10012"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10013", "value"=>"Terrathree", "id"=>"10013"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10014", "value"=>"Kartefour", "id"=>"10014"}]}]}}
453
453
  field = Jirarest2Field::CascadingField.new("customfield_10000","Cascading Select Test",{:required => false, :createmeta => fstruct["customfield_10000"]})
454
- allowed_v = [{"English"=>["One", "Two", "Three", "Four"]}, {"German"=>["Eins", "zwei", "drEi", "vier"]}, {"ISO"=>["Unaone", "Bissotwo", "Terrathree", "Kartefour"]}]
454
+ allowed_v = [{"English"=>["One", "Two", "Three", "Four"], "German"=>["Eins", "zwei", "drEi", "vier"], "ISO"=>["Unaone", "Bissotwo", "Terrathree", "Kartefour"]}]
455
455
  assert_equal "customfield_10000", field.id
456
456
  assert_equal "Cascading Select Test", field.name
457
457
  assert_equal false, field.readonly
@@ -346,14 +346,21 @@ module Jirarest2Field
346
346
  end
347
347
 
348
348
  def test_allowed
349
- @field.allowed_values= [{ "color" => ["red","green","yellow"],"car" => ["bmw","mini","mg","vw"], "lang" => ["ruby","Java","C","C#"]}]
349
+ @field.allowed_values= [{ "color" => ["red","green","yellow"],"car" => ["bmw","mini","mg","vw"],"lang" => ["ruby","Java","C","C#"]}]
350
350
  @field.value = ["color","red"]
351
+ assert_equal ["color","red"],@field.value
351
352
  @field.value = ["car","mg"]
353
+ assert_equal ["car","mg"],@field.value
352
354
  assert_raises(Jirarest2::ValueNotAllowedException) { @field.value = ["color","lang"] }
353
355
  assert_raises(Jirarest2::ValueNotAllowedException) { @field.value = ["color"] }
354
356
  assert_raises(Jirarest2::ValueNotAllowedException) { @field.value = ["music"] }
355
357
  assert_raises(Jirarest2::ValueNotAllowedException) { @field.value = ["music","Cello"] }
356
358
  end
359
+
360
+ def test_allowed_with_empties
361
+ @field.allowed_values = [{ "color" => ["red","green","yellow"],"car" => [nil],"lang" => ["ruby","Java","C","C#"]}]
362
+ @field.value = ["car","nil"]
363
+ end
357
364
 
358
365
  end # class TestCascadingField
359
366
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jirarest2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -50,11 +50,11 @@ cert_chain:
50
50
  -----END CERTIFICATE-----
51
51
 
52
52
  '
53
- date: 2012-09-19 00:00:00.000000000 Z
53
+ date: 2012-09-20 00:00:00.000000000 Z
54
54
  dependencies:
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: json
57
- requirement: &14796920 !ruby/object:Gem::Requirement
57
+ requirement: &14487300 !ruby/object:Gem::Requirement
58
58
  none: false
59
59
  requirements:
60
60
  - - ! '>='
@@ -62,10 +62,10 @@ dependencies:
62
62
  version: 1.6.0
63
63
  type: :runtime
64
64
  prerelease: false
65
- version_requirements: *14796920
65
+ version_requirements: *14487300
66
66
  - !ruby/object:Gem::Dependency
67
67
  name: highline
68
- requirement: &14796100 !ruby/object:Gem::Requirement
68
+ requirement: &14482800 !ruby/object:Gem::Requirement
69
69
  none: false
70
70
  requirements:
71
71
  - - ! '>='
@@ -73,10 +73,10 @@ dependencies:
73
73
  version: 1.1.0
74
74
  type: :runtime
75
75
  prerelease: false
76
- version_requirements: *14796100
76
+ version_requirements: *14482800
77
77
  - !ruby/object:Gem::Dependency
78
78
  name: hoe-yard
79
- requirement: &14795620 !ruby/object:Gem::Requirement
79
+ requirement: &14481280 !ruby/object:Gem::Requirement
80
80
  none: false
81
81
  requirements:
82
82
  - - ! '>='
@@ -84,10 +84,10 @@ dependencies:
84
84
  version: 0.1.2
85
85
  type: :development
86
86
  prerelease: false
87
- version_requirements: *14795620
87
+ version_requirements: *14481280
88
88
  - !ruby/object:Gem::Dependency
89
89
  name: webmock
90
- requirement: &14794880 !ruby/object:Gem::Requirement
90
+ requirement: &14479940 !ruby/object:Gem::Requirement
91
91
  none: false
92
92
  requirements:
93
93
  - - ! '>='
@@ -95,10 +95,10 @@ dependencies:
95
95
  version: 1.7.0
96
96
  type: :development
97
97
  prerelease: false
98
- version_requirements: *14794880
98
+ version_requirements: *14479940
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: hoe
101
- requirement: &14793720 !ruby/object:Gem::Requirement
101
+ requirement: &14478520 !ruby/object:Gem::Requirement
102
102
  none: false
103
103
  requirements:
104
104
  - - ! '>='
@@ -106,7 +106,7 @@ dependencies:
106
106
  version: 2.9.4
107
107
  type: :development
108
108
  prerelease: false
109
- version_requirements: *14793720
109
+ version_requirements: *14478520
110
110
  description: ! "jirarest2 is yet another implementation of the JIRA(tm) REST-API[https://developer.atlassian.com/display/JIRADEV/JIRA+Remote+API+Reference]
111
111
  . This one for Ruby1.9.1\n\nIt is intended to be called within the shell to create
112
112
  and verify JIRA(tm) issues fast without a browser. There was no particular need
metadata.gz.sig CHANGED
Binary file