jirarest2 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/lib/jirarest2/result.rb
CHANGED
@@ -35,23 +35,16 @@ module Jirarest2
|
|
35
35
|
|
36
36
|
|
37
37
|
# Show the result in a more usable form
|
38
|
-
# @param [Net::HTTPResponse]
|
38
|
+
# @param [Net::HTTPResponse] httpResponse
|
39
39
|
def initialize(httpResponse)
|
40
|
-
# pp httpResponse
|
41
|
-
# pp httpResponse.class
|
42
|
-
# pp httpResponse.body
|
43
40
|
@code = httpResponse.code
|
44
41
|
@header = httpResponse.to_hash
|
45
42
|
@body = httpResponse.body
|
46
|
-
#pp @body
|
47
43
|
if httpResponse.instance_of?(Net::HTTPNoContent) or httpResponse.body == "" or httpResponse.body.nil? then # If there is nothing in the body it would be hard to parse it.
|
48
44
|
@result = @body
|
49
45
|
else
|
50
46
|
@result = JSON.parse(@body)
|
51
47
|
end
|
52
|
-
#pp @code
|
53
|
-
#pp @header
|
54
|
-
|
55
48
|
end # initialize
|
56
49
|
|
57
50
|
end # class
|
data/lib/jirarest2/services.rb
CHANGED
@@ -20,7 +20,7 @@ require_relative "connect"
|
|
20
20
|
# Trying to keep the services together in one class so I don't have to write so much
|
21
21
|
class Services
|
22
22
|
|
23
|
-
# @param [Connection]
|
23
|
+
# @param [Connection] connection A connection Object
|
24
24
|
def initialize(connection)
|
25
25
|
@connection = connection
|
26
26
|
# to be set in each subclass;
|
@@ -58,6 +58,7 @@ class IssueLink < Services
|
|
58
58
|
# @param [String, Issue] remoteIssue Issue to connect to
|
59
59
|
# @param [String] type Link type
|
60
60
|
# @param [String] comment If a comment should be set while linking
|
61
|
+
# @raise [Jirarest2::ValueNotAllowedException.new] Raised if the name give for the linktype is not valid
|
61
62
|
# @return [Jirarest2::Result] The result of the linking
|
62
63
|
def link_issue(thisIssue,remoteIssue,type,comment = nil)
|
63
64
|
inwardIssue = key(thisIssue)
|
data/lib/jirarest2bin.rb
CHANGED
@@ -23,7 +23,7 @@ require "ostruct"
|
|
23
23
|
require "jirarest2/madbitconfig"
|
24
24
|
require "uri"
|
25
25
|
|
26
|
-
|
26
|
+
# Module to keep some methods most executable scripts need
|
27
27
|
module Jirarest2Bin
|
28
28
|
# Checks for the minimum jira version (1.9.1)
|
29
29
|
def self.check_ruby_version
|
@@ -156,7 +156,7 @@ module Jirarest2Bin
|
|
156
156
|
# @param [Array] scriptopts Command line options from the calling script
|
157
157
|
# @param [Connection,Nil] connection a connection we er to use
|
158
158
|
# @param [Symbol] command to execute
|
159
|
-
# @param [Array]
|
159
|
+
# @param [Array] args Arguments for the commands to call
|
160
160
|
# @return [Connection] The connection we used
|
161
161
|
# @return [Object] The object that was called in the command
|
162
162
|
# @example get a Connection object
|
@@ -0,0 +1 @@
|
|
1
|
+
{"expand":"projects","projects":[{"expand":"issuetypes","self":"http://localhost:2990/jira/rest/api/2/project/MFTP","id":"10000","key":"MFTP","name":"My first Test Project","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/projectavatar?size=small&pid=10000&avatarId=10011","48x48":"http://localhost:2990/jira/secure/projectavatar?pid=10000&avatarId=10011"},"issuetypes":[{"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"]},"timetracking":{"required":false,"schema":{"type":"timetracking","system":"timetracking"},"name":"Time Tracking","operations":["set","edit"]},"customfield_10306":{"required":false,"schema":{"type":"version","custom":"com.atlassian.jira.plugin.system.customfieldtypes:version","customId":10306},"name":"Single Version Picker Field","operations":["set"],"allowedValues":[[{"self":"http://localhost:2990/jira/rest/api/2/version/10000","id":"10000","description":"Version 0.1 dooh","name":"0.1","archived":false,"released":false,"releaseDate":"2012-07-01"},{"self":"http://localhost:2990/jira/rest/api/2/version/10001","id":"10001","description":"And now v0.2","name":"0.2","archived":false,"released":false,"releaseDate":"2012-08-01"},{"self":"http://localhost:2990/jira/rest/api/2/version/10002","id":"10002","description":"Version 0.3","name":"0.3","archived":false,"released":false,"releaseDate":"2012-08-31"}]]},"customfield_10309":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jirafisheyeplugin:hiddenjobswitch","customId":10309},"name":"Job Switch (Hidden)","operations":["set"]},"customfield_10308":{"required":false,"schema":{"type":"array","items":"version","custom":"com.atlassian.jira.plugin.system.customfieldtypes:multiversion","customId":10308},"name":"Multi Version Picker","operations":["set","add","remove"],"allowedValues":[[{"self":"http://localhost:2990/jira/rest/api/2/version/10000","id":"10000","description":"Version 0.1 dooh","name":"0.1","archived":false,"released":false,"releaseDate":"2012-07-01"},{"self":"http://localhost:2990/jira/rest/api/2/version/10001","id":"10001","description":"And now v0.2","name":"0.2","archived":false,"released":false,"releaseDate":"2012-08-01"},{"self":"http://localhost:2990/jira/rest/api/2/version/10002","id":"10002","description":"Version 0.3","name":"0.3","archived":false,"released":false,"releaseDate":"2012-08-31"}]]},"issuetype":{"required":true,"schema":{"type":"issuetype","system":"issuetype"},"name":"Issue Type","operations":[],"allowedValues":[{"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}]},"customfield_10303":{"required":false,"schema":{"type":"array","items":"group","custom":"com.atlassian.jira.plugin.system.customfieldtypes:multigrouppicker","customId":10303},"name":"Multi Group","operations":["add","set","remove"]},"customfield_10302":{"required":false,"schema":{"type":"number","custom":"com.atlassian.jira.plugin.system.customfieldtypes:importid","customId":10302},"name":"Import ID Field range search","operations":["set"]},"customfield_10305":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:readonlyfield","customId":10305},"name":"RO Text Field","operations":["set"]},"customfield_10304":{"required":false,"schema":{"type":"project","custom":"com.atlassian.jira.plugin.system.customfieldtypes:project","customId":10304},"name":"Project Picket Field","operations":["set"],"allowedValues":[[{"self":"http://localhost:2990/jira/rest/api/2/project/MFTP","id":"10000","key":"MFTP","name":"My first Test Project","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/projectavatar?size=small&pid=10000&avatarId=10011","48x48":"http://localhost:2990/jira/secure/projectavatar?pid=10000&avatarId=10011"}},{"self":"http://localhost:2990/jira/rest/api/2/project/SP","id":"10100","key":"SP","name":"Second Project","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/projectavatar?size=small&pid=10100&avatarId=10011","48x48":"http://localhost:2990/jira/secure/projectavatar?pid=10100&avatarId=10011"}}]]},"resolution":{"required":false,"schema":{"type":"resolution","system":"resolution"},"name":"Resolution","operations":["set"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/resolution/1","name":"Fixed","id":"1"},{"self":"http://localhost:2990/jira/rest/api/2/resolution/2","name":"Won't Fix","id":"2"},{"self":"http://localhost:2990/jira/rest/api/2/resolution/3","name":"Duplicate","id":"3"},{"self":"http://localhost:2990/jira/rest/api/2/resolution/4","name":"Incomplete","id":"4"},{"self":"http://localhost:2990/jira/rest/api/2/resolution/5","name":"Cannot Reproduce","id":"5"}]},"fixVersions":{"required":false,"schema":{"type":"array","items":"version","system":"fixVersions"},"name":"Fix Version/s","operations":["set","add","remove"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/version/10000","id":"10000","description":"Version 0.1 dooh","name":"0.1","archived":false,"released":false,"releaseDate":"2012-07-01","overdue":true,"userReleaseDate":"01/Jul/12"},{"self":"http://localhost:2990/jira/rest/api/2/version/10001","id":"10001","description":"And now v0.2","name":"0.2","archived":false,"released":false,"releaseDate":"2012-08-01","overdue":true,"userReleaseDate":"01/Aug/12"},{"self":"http://localhost:2990/jira/rest/api/2/version/10002","id":"10002","description":"Version 0.3","name":"0.3","archived":false,"released":false,"releaseDate":"2012-08-31","overdue":false,"userReleaseDate":"31/Aug/12"}]},"reporter":{"required":true,"schema":{"type":"user","system":"reporter"},"name":"Reporter","autoCompleteUrl":"http://localhost:2990/jira/rest/api/latest/user/search?username=","operations":["set"]},"description":{"required":false,"schema":{"type":"string","system":"description"},"name":"Description","operations":["set"]},"priority":{"required":false,"schema":{"type":"priority","system":"priority"},"name":"Priority","operations":["set"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/priority/1","iconUrl":"http://localhost:2990/jira/images/icons/priority_blocker.gif","name":"Blocker","id":"1"},{"self":"http://localhost:2990/jira/rest/api/2/priority/2","iconUrl":"http://localhost:2990/jira/images/icons/priority_critical.gif","name":"Critical","id":"2"},{"self":"http://localhost:2990/jira/rest/api/2/priority/3","iconUrl":"http://localhost:2990/jira/images/icons/priority_major.gif","name":"Major","id":"3"},{"self":"http://localhost:2990/jira/rest/api/2/priority/4","iconUrl":"http://localhost:2990/jira/images/icons/priority_minor.gif","name":"Minor","id":"4"},{"self":"http://localhost:2990/jira/rest/api/2/priority/5","iconUrl":"http://localhost:2990/jira/images/icons/priority_trivial.gif","name":"Trivial","id":"5"}]},"customfield_10001":{"required":false,"schema":{"type":"datetime","custom":"com.atlassian.jira.plugin.system.customfieldtypes:datetime","customId":10001},"name":"Date Time Field","operations":["set"]},"duedate":{"required":false,"schema":{"type":"date","system":"duedate"},"name":"Due Date","operations":["set"]},"customfield_10002":{"required":false,"schema":{"type":"date","custom":"com.atlassian.jira.plugin.system.customfieldtypes:datepicker","customId":10002},"name":"Date Picker","operations":["set"]},"customfield_10310":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jirafisheyeplugin:jobcheckbox","customId":10310},"name":"Job Checkbox","operations":["set"]},"customfield_10003":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:textarea","customId":10003},"name":"Großes Text","operations":["set"]},"customfield_10311":{"required":false,"schema":{"type":"number","custom":"com.atlassian.jira.plugin.system.customfieldtypes:float","customId":10311},"name":"Numbers no","operations":["set"]},"customfield_10004":{"required":false,"schema":{"type":"array","items":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes","customId":10004},"name":"Multi Checkboxes","operations":["add","set","remove"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10019","value":"Göthe","id":"10019"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10020","value":"Schiller","id":"10020"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10021","value":"Heine","id":"10021"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10022","value":"Kafka","id":"10022"}]},"customfield_10312":{"required":false,"schema":{"type":"number","custom":"com.atlassian.jira.plugin.system.customfieldtypes:float","customId":10312},"name":"Numbers range","operations":["set"]},"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"}]}]},"customfield_10102":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:textfield","customId":10102},"name":"projects","operations":["set"]},"customfield_10101":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:textfield","customId":10101},"name":"Issue Type","operations":["set"]},"customfield_10100":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:textfield","customId":10100},"name":"issuetype","operations":["set"]},"customfield_10006":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:select","customId":10006},"name":"List select","operations":["set"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10015","value":"Räuber","id":"10015"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10016","value":"Kabale und Liebe","id":"10016"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10017","value":"Faust","id":"10017"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10018","value":"Landleben","id":"10018"}]},"customfield_10005":{"required":false,"schema":{"type":"array","items":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:multiselect","customId":10005},"name":"Multi Select","operations":["add","set","remove"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10023","value":"Glocke","id":"10023"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10024","value":"Kabale und Liebe","id":"10024"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10025","value":"Schiller","id":"10025"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10026","value":"Göthe","id":"10026"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10027","value":"Faust","id":"10027"}]},"labels":{"required":false,"schema":{"type":"array","items":"string","system":"labels"},"name":"Labels","autoCompleteUrl":"http://localhost:2990/jira/rest/api/1.0/labels/suggest?query=","operations":["add","set","remove"]},"customfield_10315":{"required":false,"schema":{"type":"user","custom":"com.atlassian.jira.plugin.system.customfieldtypes:userpicker","customId":10315},"name":"User Picker User","autoCompleteUrl":"http://localhost:2990/jira/rest/api/1.0/users/picker?fieldName=customfield_10315&query=","operations":["set"]},"assignee":{"required":false,"schema":{"type":"user","system":"assignee"},"name":"Assignee","autoCompleteUrl":"http://localhost:2990/jira/rest/api/latest/user/assignable/search?issueKey=null&username=","operations":["set"]},"customfield_10316":{"required":false,"schema":{"type":"user","custom":"com.atlassian.jira.plugin.system.customfieldtypes:userpicker","customId":10316},"name":"User Picker U+G","autoCompleteUrl":"http://localhost:2990/jira/rest/api/1.0/users/picker?fieldName=customfield_10316&query=","operations":["set"]},"customfield_10313":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons","customId":10313},"name":"Radios","operations":["set"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10100","value":"Books","id":"10100"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10101","value":"EBooks","id":"10101"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10102","value":"Newspaper","id":"10102"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10103","value":"Websites","id":"10103"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10104","value":"Magazines","id":"10104"}]},"customfield_10314":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:select","customId":10314},"name":"Select List Multi","operations":["set"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10105","value":"Car","id":"10105"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10106","value":"Train","id":"10106"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10107","value":"Subway","id":"10107"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10108","value":"Underground","id":"10108"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10109","value":"Plane","id":"10109"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10110","value":"Ship","id":"10110"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10111","value":"Hovercraft","id":"10111"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10112","value":"Foot","id":"10112"}]},"attachment":{"required":false,"schema":{"type":"array","items":"attachment","system":"attachment"},"name":"Attachment","operations":[]},"customfield_10200":{"required":false,"schema":{"type":"array","items":"user","custom":"com.atlassian.jira.plugin.system.customfieldtypes:multiuserpicker","customId":10200},"name":"Multi User","autoCompleteUrl":"http://localhost:2990/jira/rest/api/1.0/users/picker?fieldName=customfield_10200&query=","operations":["add","set","remove"]},"project":{"required":true,"schema":{"type":"project","system":"project"},"autoCompleteUrl":"Project","operations":["set"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/project/MFTP","id":"10000","key":"MFTP","name":"My first Test Project","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/projectavatar?size=small&pid=10000&avatarId=10011","48x48":"http://localhost:2990/jira/secure/projectavatar?pid=10000&avatarId=10011"}}]},"versions":{"required":false,"schema":{"type":"array","items":"version","system":"versions"},"name":"Affects Version/s","operations":["set","add","remove"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/version/10000","id":"10000","description":"Version 0.1 dooh","name":"0.1","archived":false,"released":false,"releaseDate":"2012-07-01","overdue":true,"userReleaseDate":"01/Jul/12"},{"self":"http://localhost:2990/jira/rest/api/2/version/10001","id":"10001","description":"And now v0.2","name":"0.2","archived":false,"released":false,"releaseDate":"2012-08-01","overdue":true,"userReleaseDate":"01/Aug/12"},{"self":"http://localhost:2990/jira/rest/api/2/version/10002","id":"10002","description":"Version 0.3","name":"0.3","archived":false,"released":false,"releaseDate":"2012-08-31","overdue":false,"userReleaseDate":"31/Aug/12"}]},"environment":{"required":false,"schema":{"type":"string","system":"environment"},"name":"Environment","operations":["set"]},"customfield_10300":{"required":false,"schema":{"type":"group","custom":"com.atlassian.jira.plugin.system.customfieldtypes:grouppicker","customId":10300},"name":"Pick Group","operations":["set"]},"customfield_10301":{"required":false,"schema":{"type":"number","custom":"com.atlassian.jira.plugin.system.customfieldtypes:importid","customId":10301},"name":"Import ID Field no search","operations":["set"]},"components":{"required":false,"schema":{"type":"array","items":"component","system":"components"},"name":"Component/s","operations":["add","set","remove"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/component/10000","id":"10000","name":"Signal1","description":"A component "},{"self":"http://localhost:2990/jira/rest/api/2/component/10001","id":"10001","name":"Sissi","description":"Another Component"}]}}}]}]}
|
@@ -0,0 +1,820 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require "minitest/autorun"
|
3
|
+
require "jirarest2/field"
|
4
|
+
require "json"
|
5
|
+
require "deb"
|
6
|
+
|
7
|
+
# Extraclass to get all the different cases
|
8
|
+
class TestFieldCreatemeta < MiniTest::Unit::TestCase
|
9
|
+
|
10
|
+
def test_summary
|
11
|
+
fstruct = {"summary" => {"required"=>true, "schema"=>{"type"=>"string", "system"=>"summary"}, "name"=>"Summary", "operations"=>["set"]}}
|
12
|
+
field = Jirarest2Field::TextField.new("summary","Summary",{:required => false, :createmeta => fstruct["summary"]})
|
13
|
+
allowed_v = []
|
14
|
+
assert_equal "summary", field.id
|
15
|
+
assert_equal "Summary", field.name
|
16
|
+
assert_equal false, field.readonly
|
17
|
+
assert_raises(NoMethodError) { field.key }
|
18
|
+
assert_equal allowed_v, field.allowed_values
|
19
|
+
end
|
20
|
+
def test_parse_value_summary
|
21
|
+
field = Jirarest2Field::TextField.new("summary","Summary",{:required => false})
|
22
|
+
field.parse_value("All Fields Bujaa")
|
23
|
+
assert_equal "All Fields Bujaa",field.value
|
24
|
+
toj = {"summary" => "All Fields Bujaa"}
|
25
|
+
assert_equal toj, field.to_j
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_customfield_10307 # URL -> TextField
|
29
|
+
fstruct = {"customfield_10307" => {"required"=>false, "schema"=>{"type"=>"string", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:url", "customId"=>10307}, "name"=>"URL", "operations"=>["set"]}}
|
30
|
+
field = Jirarest2Field::TextField.new("customfield_10307","URL",{:required => false, :createmeta => fstruct["customfield_10307"]})
|
31
|
+
allowed_v = [] # TODO
|
32
|
+
assert_equal "customfield_10307", field.id
|
33
|
+
assert_equal "URL", field.name
|
34
|
+
assert_equal false, field.readonly
|
35
|
+
assert_raises(NoMethodError) { field.key }
|
36
|
+
assert_equal allowed_v, field.allowed_values
|
37
|
+
end
|
38
|
+
def test_parse_value_customfield_10307
|
39
|
+
field = Jirarest2Field::TextField.new("customfield_10307","URL",{:required => false})
|
40
|
+
field.parse_value("https://localhost:8080/test/test")
|
41
|
+
assert_equal "https://localhost:8080/test/test",field.value
|
42
|
+
toj = {"customfield_10307" => "https://localhost:8080/test/test"}
|
43
|
+
assert_equal toj, field.to_j
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def test_timetracking # timetracking -> TimetrackingField
|
48
|
+
fstruct = {"timetracking" => {"required"=>false, "schema"=>{"type"=>"timetracking", "system"=>"timetracking"}, "name"=>"Time Tracking", "operations"=>["set", "edit"]}}
|
49
|
+
field = Jirarest2Field::TimetrackingField.new("timetracking","Time Tracking",{:required => false, :createmeta => fstruct["timetracking"]})
|
50
|
+
allowed_v = []
|
51
|
+
assert_equal "timetracking", field.id
|
52
|
+
assert_equal "Time Tracking", field.name
|
53
|
+
assert_equal false, field.readonly
|
54
|
+
assert_raises(NoMethodError) { field.key }
|
55
|
+
assert_equal allowed_v, field.allowed_values
|
56
|
+
end
|
57
|
+
def test_parse_value_timetracking
|
58
|
+
field = Jirarest2Field::TimetrackingField.new("timetracking","Time Tracking",{:required => false})
|
59
|
+
field.parse_value({"originalEstimate"=>"46w 3d 6h", "remainingEstimate"=>"1w 3m", "originalEstimateSeconds"=>6732000, "remainingEstimateSeconds"=>144180})
|
60
|
+
ret = {"originalEstimate" => "46w 3d 6h", "remainingEstimate" => "1w 3m", "originalEstimateSeconds" => 6732000, "remainingEstimateSeconds" => 144180}
|
61
|
+
assert_equal ret,field.value
|
62
|
+
# @todo check for to_j
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
def test_customfield_10306 # Version Picker -> VersionField
|
67
|
+
fstruct = {"customfield_10306" => {"required"=>false, "schema"=>{"type"=>"version", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:version", "customId"=>10306}, "name"=>"Single Version Picker Field", "operations"=>["set"], "allowedValues"=>[[{"self"=>"http://localhost:2990/jira/rest/api/2/version/10000", "id"=>"10000", "description"=>"Version 0.1 dooh", "name"=>"0.1", "archived"=>false, "released"=>false, "releaseDate"=>"2012-07-01"}, {"self"=>"http://localhost:2990/jira/rest/api/2/version/10001", "id"=>"10001", "description"=>"And now v0.2", "name"=>"0.2", "archived"=>false, "released"=>false, "releaseDate"=>"2012-08-01"}, {"self"=>"http://localhost:2990/jira/rest/api/2/version/10002", "id"=>"10002", "description"=>"Version 0.3", "name"=>"0.3", "archived"=>false, "released"=>false, "releaseDate"=>"2012-08-31"}]]}}
|
68
|
+
field = Jirarest2Field::VersionField.new("customfield_10306","Single Version Picker Field",{:required => false, :createmeta => fstruct["customfield_10306"]})
|
69
|
+
allowed_v = ["0.1", "0.2", "0.3"]
|
70
|
+
assert_equal "customfield_10306", field.id
|
71
|
+
assert_equal "Single Version Picker Field", field.name
|
72
|
+
assert_equal false, field.readonly
|
73
|
+
assert_equal "name", field.key
|
74
|
+
assert_equal allowed_v, field.allowed_values
|
75
|
+
end
|
76
|
+
def test_parse_value_customfield_10306
|
77
|
+
assert_raises(Jirarest2::HashKeyMissingException){ Jirarest2Field::VersionField.new("customfield_10306","Single Version Picker Field",{:required => false})}
|
78
|
+
field = Jirarest2Field::VersionField.new("customfield_10306","Single Version Picker Field",{:required => false, :key => "name"})
|
79
|
+
field.parse_value({"self"=>"http://localhost:2990/jira/rest/api/2/version/10001", "id"=>"10001", "description"=>"And now v0.2", "name"=>"0.2", "archived"=>false, "released"=>false, "releaseDate"=>"2012-08-01"})
|
80
|
+
assert_equal "0.2",field.value
|
81
|
+
toj = {"customfield_10306"=>{"name"=>"0.2"}}
|
82
|
+
assert_equal toj, field.to_j
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
def test_customfield_10309 # hiddenjobswitch -> TextField
|
87
|
+
fstruct = {"customfield_10309" => {"required"=>false, "schema"=>{"type"=>"string", "custom"=>"com.atlassian.jirafisheyeplugin:hiddenjobswitch", "customId"=>10309}, "name"=>"Job Switch (Hidden)", "operations"=>["set"]}}
|
88
|
+
field = Jirarest2Field::TextField.new("customfield_10309","Job Switch (Hidden)",{:required => false, :createmeta => fstruct["customfield_10309"]})
|
89
|
+
allowed_v = []
|
90
|
+
assert_equal "customfield_10309", field.id
|
91
|
+
assert_equal "Job Switch (Hidden)", field.name
|
92
|
+
assert_equal false, field.readonly
|
93
|
+
assert_raises(NoMethodError) { field.key }
|
94
|
+
assert_equal allowed_v, field.allowed_values
|
95
|
+
end
|
96
|
+
def test_parse_value_customfield_10309
|
97
|
+
field = Jirarest2Field::TextField.new("customfield_10309","Job Switch (Hidden)",{:required => false})
|
98
|
+
field.parse_value("false")
|
99
|
+
assert_equal "false",field.value
|
100
|
+
toj = {"customfield_10309"=>"false"}
|
101
|
+
assert_equal toj, field.to_j
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_customfield_10308 # Multi Version Picker -> MultiVersionField
|
105
|
+
fstruct = {"customfield_10308" => {"required"=>false, "schema"=>{"type"=>"array", "items"=>"version", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:multiversion", "customId"=>10308}, "name"=>"Multi Version Picker", "operations"=>["set", "add", "remove"], "allowedValues"=>[[{"self"=>"http://localhost:2990/jira/rest/api/2/version/10000", "id"=>"10000", "description"=>"Version 0.1 dooh", "name"=>"0.1", "archived"=>false, "released"=>false, "releaseDate"=>"2012-07-01"}, {"self"=>"http://localhost:2990/jira/rest/api/2/version/10001", "id"=>"10001", "description"=>"And now v0.2", "name"=>"0.2", "archived"=>false, "released"=>false, "releaseDate"=>"2012-08-01"}, {"self"=>"http://localhost:2990/jira/rest/api/2/version/10002", "id"=>"10002", "description"=>"Version 0.3", "name"=>"0.3", "archived"=>false, "released"=>false, "releaseDate"=>"2012-08-31"}]]}}
|
106
|
+
field = Jirarest2Field::MultiVersionField.new("customfield_10308","Multi Version Picker",{:required => false, :createmeta => fstruct["customfield_10308"]})
|
107
|
+
allowed_v = ["0.1","0.2","0.3"]
|
108
|
+
assert_equal "customfield_10308", field.id
|
109
|
+
assert_equal "Multi Version Picker", field.name
|
110
|
+
assert_equal false, field.readonly
|
111
|
+
assert_equal "name", field.key
|
112
|
+
assert_equal allowed_v, field.allowed_values
|
113
|
+
end
|
114
|
+
def test_parse_value_customfield_10308
|
115
|
+
field = Jirarest2Field::MultiVersionField.new("customfield_10308","Multi Version Picker",{:required => false, :key => "name"})
|
116
|
+
field.parse_value([{"self"=>"http://localhost:2990/jira/rest/api/2/version/10001", "id"=>"10001", "description"=>"And now v0.2", "name"=>"0.2", "archived"=>false, "released"=>false, "releaseDate"=>"2012-08-01"}, {"self"=>"http://localhost:2990/jira/rest/api/2/version/10002", "id"=>"10002", "description"=>"Version 0.3", "name"=>"0.3", "archived"=>false, "released"=>false, "releaseDate"=>"2012-08-31"}])
|
117
|
+
assert_equal ["0.2","0.3"],field.value
|
118
|
+
toj = {"customfield_10308" => [{"name" => "0.2"},{"name" => "0.3"}]}
|
119
|
+
assert_equal toj, field.to_j
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_issuetype # issuetype -> HashField
|
123
|
+
fstruct = {"issuetype" => {"required"=>true, "schema"=>{"type"=>"issuetype", "system"=>"issuetype"}, "name"=>"Issue Type", "operations"=>[], "allowedValues"=>[{"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}]}}
|
124
|
+
field = Jirarest2Field::HashField.new("issuetype","Issue Type",{:required => false, :createmeta => fstruct["issuetype"]})
|
125
|
+
allowed_v = ["My issue type"]
|
126
|
+
assert_equal "issuetype", field.id
|
127
|
+
assert_equal "Issue Type", field.name
|
128
|
+
assert_equal true, field.readonly
|
129
|
+
assert_equal "name", field.key
|
130
|
+
assert_equal "My issue type", field.value
|
131
|
+
assert_equal allowed_v, field.allowed_values
|
132
|
+
end
|
133
|
+
def test_parse_value_issuetype
|
134
|
+
assert_raises(Jirarest2::HashKeyMissingException) { Jirarest2Field::HashField.new("issuetype","Issue Type",{:required => false})}
|
135
|
+
field = Jirarest2Field::HashField.new("issuetype","Issue Type",{:required => false, :key => "name"})
|
136
|
+
field.parse_value({"self"=>"http://localhost:2990/jira/rest/api/2/issuetype/1", "id"=>"1", "description"=>"A problem which impairs or prevents the functions of the product.", "iconUrl"=>"http://localhost:2990/jira/images/icons/bug.gif", "name"=>"Bug", "subtask"=>false})
|
137
|
+
assert_equal "Bug",field.value
|
138
|
+
toj = {"issuetype" => {"name" => "Bug"} }
|
139
|
+
assert_equal toj, field.to_j
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_customfield_10303 # multigroupPicker -> MultiUserField
|
143
|
+
fstruct = {"customfield_10303" => {"required"=>false, "schema"=>{"type"=>"array", "items"=>"group", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:multigrouppicker", "customId"=>10303}, "name"=>"Multi Group", "operations"=>["add", "set", "remove"]}}
|
144
|
+
field = Jirarest2Field::MultiUserField.new("customfield_10303","Multi Group",{:required => false, :createmeta => fstruct["customfield_10303"]})
|
145
|
+
allowed_v = []
|
146
|
+
assert_equal "customfield_10303", field.id
|
147
|
+
assert_equal "Multi Group", field.name
|
148
|
+
assert_equal false, field.readonly
|
149
|
+
assert_equal "name", field.key
|
150
|
+
assert_equal allowed_v, field.allowed_values
|
151
|
+
end
|
152
|
+
def test_parse_value_customfield_10303
|
153
|
+
field = Jirarest2Field::MultiUserField.new("customfield_10303","Multi Group",{:required => false, :key => "name"})
|
154
|
+
field.parse_value( [{"name"=>"jira-administrators"}, {"name"=>"jira-users"}])
|
155
|
+
assert_equal ["jira-administrators","jira-users"],field.value
|
156
|
+
toj = { "customfield_10303" => [{"name" => "jira-administrators"},{"name" => "jira-users" }]}
|
157
|
+
assert_equal toj, field.to_j
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_customfield_10302 # importid -> NumberField
|
161
|
+
fstruct = {"customfield_10302" => {"required"=>false, "schema"=>{"type"=>"number", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:importid", "customId"=>10302}, "name"=>"Import ID Field range search", "operations"=>["set"]}}
|
162
|
+
field = Jirarest2Field::NumberField.new("customfield_10302","Import ID Field range search",{:required => false, :createmeta => fstruct["customfield_10302"]})
|
163
|
+
allowed_v = []
|
164
|
+
assert_equal "customfield_10302", field.id
|
165
|
+
assert_equal "Import ID Field range search", field.name
|
166
|
+
assert_equal false, field.readonly
|
167
|
+
assert_raises(NoMethodError) { field.key }
|
168
|
+
assert_equal allowed_v, field.allowed_values
|
169
|
+
end
|
170
|
+
def test_parse_value_customfield_10302
|
171
|
+
field = Jirarest2Field::NumberField.new("customfield_10302","Import ID Field range search",{:required => false})
|
172
|
+
field.parse_value(nil)
|
173
|
+
assert_equal nil,field.value
|
174
|
+
toj = nil
|
175
|
+
assert_equal toj, field.to_j
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_customfield_10305 # readonlyfield -> TextField
|
179
|
+
fstruct = {"customfield_10305" => {"required"=>false, "schema"=>{"type"=>"string", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:readonlyfield", "customId"=>10305}, "name"=>"RO Text Field", "operations"=>["set"]}}
|
180
|
+
field = Jirarest2Field::TextField.new("customfield_10305","RO Text Field",{:required => false, :createmeta => fstruct["customfield_10305"]})
|
181
|
+
allowed_v = []
|
182
|
+
assert_equal "customfield_10305", field.id
|
183
|
+
assert_equal "RO Text Field", field.name
|
184
|
+
assert_equal false, field.readonly
|
185
|
+
assert_raises(NoMethodError) { field.key }
|
186
|
+
assert_equal allowed_v, field.allowed_values
|
187
|
+
end
|
188
|
+
def test_parse_value_customfield_10305
|
189
|
+
field = Jirarest2Field::TextField.new("customfield_10305","RO Text Field",{:required => false})
|
190
|
+
field.parse_value(nil)
|
191
|
+
assert_equal nil,field.value
|
192
|
+
toj = nil
|
193
|
+
assert_equal toj, field.to_j
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_customfield_10304 # project -> ProjectField
|
197
|
+
fstruct = {"customfield_10304" => {"required"=>false, "schema"=>{"type"=>"project", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:project", "customId"=>10304}, "name"=>"Project Picket Field", "operations"=>["set"], "allowedValues"=>[[{"self"=>"http://localhost:2990/jira/rest/api/2/project/MFTP", "id"=>"10000", "key"=>"MFTP", "name"=>"My first Test Project", "avatarUrls"=>{"16x16"=>"http://localhost:2990/jira/secure/projectavatar?size=small&pid=10000&avatarId=10011", "48x48"=>"http://localhost:2990/jira/secure/projectavatar?pid=10000&avatarId=10011"}}, {"self"=>"http://localhost:2990/jira/rest/api/2/project/SP", "id"=>"10100", "key"=>"SP", "name"=>"Second Project", "avatarUrls"=>{"16x16"=>"http://localhost:2990/jira/secure/projectavatar?size=small&pid=10100&avatarId=10011", "48x48"=>"http://localhost:2990/jira/secure/projectavatar?pid=10100&avatarId=10011"}}]]}}
|
198
|
+
field = Jirarest2Field::ProjectField.new("customfield_10304","Project Picket Field",{:required => false, :createmeta => fstruct["customfield_10304"]})
|
199
|
+
# allowed_v = ["My first Test Project", "Second Project"]
|
200
|
+
allowed_v = ["MFTP", "SP"]
|
201
|
+
assert_equal "customfield_10304", field.id
|
202
|
+
assert_equal "Project Picket Field", field.name
|
203
|
+
assert_equal false, field.readonly
|
204
|
+
assert_equal "key", field.key
|
205
|
+
assert_equal allowed_v, field.allowed_values
|
206
|
+
end
|
207
|
+
def test_parse_value_customfield_10304
|
208
|
+
field = Jirarest2Field::ProjectField.new("customfield_10304","Project Picket Field",{:required => false, :key => "key"})
|
209
|
+
field.parse_value({"self"=>"http://localhost:2990/jira/rest/api/2/project/MFTP", "id"=>"10000", "key"=>"MFTP", "name"=>"My first Test Project", "avatarUrls"=>{"16x16"=>"http://localhost:2990/jira/secure/projectavatar?size=small&pid=10000&avatarId=10011", "48x48"=>"http://localhost:2990/jira/secure/projectavatar?pid=10000&avatarId=10011"}})
|
210
|
+
assert_equal "MFTP",field.value
|
211
|
+
toj = {"customfield_10304" => {"key" => "MFTP"}}
|
212
|
+
assert_equal toj, field.to_j
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_resolution # resolution -> HashField
|
216
|
+
fstruct = {"resolution" => {"required"=>false, "schema"=>{"type"=>"resolution", "system"=>"resolution"}, "name"=>"Resolution", "operations"=>["set"], "allowedValues"=>[{"self"=>"http://localhost:2990/jira/rest/api/2/resolution/1", "name"=>"Fixed", "id"=>"1"}, {"self"=>"http://localhost:2990/jira/rest/api/2/resolution/2", "name"=>"Won't Fix", "id"=>"2"}, {"self"=>"http://localhost:2990/jira/rest/api/2/resolution/3", "name"=>"Duplicate", "id"=>"3"}, {"self"=>"http://localhost:2990/jira/rest/api/2/resolution/4", "name"=>"Incomplete", "id"=>"4"}, {"self"=>"http://localhost:2990/jira/rest/api/2/resolution/5", "name"=>"Cannot Reproduce", "id"=>"5"}]}}
|
217
|
+
field = Jirarest2Field::HashField.new("resolution","Resolution",{:required => false, :createmeta => fstruct["resolution"]})
|
218
|
+
allowed_v = ["Fixed", "Won't Fix", "Duplicate", "Incomplete", "Cannot Reproduce"]
|
219
|
+
assert_equal "resolution", field.id
|
220
|
+
assert_equal "Resolution", field.name
|
221
|
+
assert_equal false, field.readonly
|
222
|
+
assert_equal "name", field.key
|
223
|
+
assert_equal allowed_v, field.allowed_values
|
224
|
+
end
|
225
|
+
def test_parse_value_resolution
|
226
|
+
field = Jirarest2Field::HashField.new("resolution","Resolution",{:required => false, :key => "name"})
|
227
|
+
field.parse_value(nil)
|
228
|
+
assert_equal nil,field.value
|
229
|
+
# @todo see if there is not a better test here
|
230
|
+
toj = nil
|
231
|
+
assert_equal toj, field.to_j
|
232
|
+
end
|
233
|
+
|
234
|
+
def test_fixVersions # version -> MultiVersionField
|
235
|
+
fstruct = {"fixVersions" => {"required"=>false, "schema"=>{"type"=>"array", "items"=>"version", "system"=>"fixVersions"}, "name"=>"Fix Version/s", "operations"=>["set", "add", "remove"], "allowedValues"=>[{"self"=>"http://localhost:2990/jira/rest/api/2/version/10000", "id"=>"10000", "description"=>"Version 0.1 dooh", "name"=>"0.1", "archived"=>false, "released"=>false, "releaseDate"=>"2012-07-01", "overdue"=>true, "userReleaseDate"=>"01/Jul/12"}, {"self"=>"http://localhost:2990/jira/rest/api/2/version/10001", "id"=>"10001", "description"=>"And now v0.2", "name"=>"0.2", "archived"=>false, "released"=>false, "releaseDate"=>"2012-08-01", "overdue"=>true, "userReleaseDate"=>"01/Aug/12"}, {"self"=>"http://localhost:2990/jira/rest/api/2/version/10002", "id"=>"10002", "description"=>"Version 0.3", "name"=>"0.3", "archived"=>false, "released"=>false, "releaseDate"=>"2012-08-31", "overdue"=>false, "userReleaseDate"=>"31/Aug/12"}]}}
|
236
|
+
field = Jirarest2Field::MultiVersionField.new("fixVersions","Fix Version/s",{:required => false, :createmeta => fstruct["fixVersions"]})
|
237
|
+
allowed_v = ["0.1","0.2","0.3"]
|
238
|
+
assert_equal "fixVersions", field.id
|
239
|
+
assert_equal "Fix Version/s", field.name
|
240
|
+
assert_equal false, field.readonly
|
241
|
+
assert_equal "name", field.key
|
242
|
+
assert_equal allowed_v, field.allowed_values
|
243
|
+
end
|
244
|
+
def test_parse_value_fixVersions
|
245
|
+
field = Jirarest2Field::MultiVersionField.new("fixVersions","Fix Version/s",{:required => false, :key => "name"})
|
246
|
+
field.parse_value([{"self"=>"http://localhost:2990/jira/rest/api/2/version/10002", "id"=>"10002", "description"=>"Version 0.3", "name"=>"0.3", "archived"=>false, "released"=>false, "releaseDate"=>"2012-08-31"}])
|
247
|
+
assert_equal ["0.3"],field.value
|
248
|
+
toj = { "fixVersions" => [{"name" => "0.3"}]}
|
249
|
+
assert_equal toj, field.to_j
|
250
|
+
end
|
251
|
+
|
252
|
+
def test_reporter # user -> UserField
|
253
|
+
fstruct = {"reporter" => {"required"=>true, "schema"=>{"type"=>"user", "system"=>"reporter"}, "name"=>"Reporter", "autoCompleteUrl"=>"http://localhost:2990/jira/rest/api/latest/user/search?username=", "operations"=>["set"]}}
|
254
|
+
field = Jirarest2Field::UserField.new("reporter","Reporter",{:required => false, :createmeta => fstruct["reporter"]})
|
255
|
+
allowed_v = []
|
256
|
+
assert_equal "reporter", field.id
|
257
|
+
assert_equal "Reporter", field.name
|
258
|
+
assert_equal false, field.readonly
|
259
|
+
assert_equal "name", field.key
|
260
|
+
assert_equal allowed_v, field.allowed_values
|
261
|
+
end
|
262
|
+
def test_parse_value_reporter
|
263
|
+
field = Jirarest2Field::UserField.new("reporter","Reporter",{:required => false, :key => "name"})
|
264
|
+
field.parse_value( {"self"=>"http://localhost:2990/jira/rest/api/2/user?username=admin", "name"=>"admin", "emailAddress"=>"admin@example.com", "avatarUrls"=>{"16x16"=>"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122", "48x48"=>"http://localhost:2990/jira/secure/useravatar?avatarId=10122"}, "displayName"=>"admin", "active"=>true})
|
265
|
+
assert_equal "admin",field.value
|
266
|
+
toj = {"reporter" => {"name" => "admin"}}
|
267
|
+
assert_equal toj, field.to_j
|
268
|
+
end
|
269
|
+
|
270
|
+
def test_description # description -> TextField
|
271
|
+
fstruct = {"description" => {"required"=>false, "schema"=>{"type"=>"string", "system"=>"description"}, "name"=>"Description", "operations"=>["set"]}}
|
272
|
+
field = Jirarest2Field::TextField.new("description","Description",{:required => false, :createmeta => fstruct["description"]})
|
273
|
+
allowed_v = []
|
274
|
+
assert_equal "description", field.id
|
275
|
+
assert_equal "Description", field.name
|
276
|
+
assert_equal false, field.readonly
|
277
|
+
assert_raises(NoMethodError) { field.key }
|
278
|
+
assert_equal allowed_v, field.allowed_values
|
279
|
+
end
|
280
|
+
def test_parse_value_description
|
281
|
+
field = Jirarest2Field::TextField.new("description","Description",{:required => false})
|
282
|
+
field.parse_value("What do you want me to describe?")
|
283
|
+
assert_equal "What do you want me to describe?",field.value
|
284
|
+
toj = {"description" => "What do you want me to describe?"}
|
285
|
+
assert_equal toj, field.to_j
|
286
|
+
end
|
287
|
+
|
288
|
+
def test_priority # priority -> HashField
|
289
|
+
fstruct = {"priority" => {"required"=>false, "schema"=>{"type"=>"priority", "system"=>"priority"}, "name"=>"Priority", "operations"=>["set"], "allowedValues"=>[{"self"=>"http://localhost:2990/jira/rest/api/2/priority/1", "iconUrl"=>"http://localhost:2990/jira/images/icons/priority_blocker.gif", "name"=>"Blocker", "id"=>"1"}, {"self"=>"http://localhost:2990/jira/rest/api/2/priority/2", "iconUrl"=>"http://localhost:2990/jira/images/icons/priority_critical.gif", "name"=>"Critical", "id"=>"2"}, {"self"=>"http://localhost:2990/jira/rest/api/2/priority/3", "iconUrl"=>"http://localhost:2990/jira/images/icons/priority_major.gif", "name"=>"Major", "id"=>"3"}, {"self"=>"http://localhost:2990/jira/rest/api/2/priority/4", "iconUrl"=>"http://localhost:2990/jira/images/icons/priority_minor.gif", "name"=>"Minor", "id"=>"4"}, {"self"=>"http://localhost:2990/jira/rest/api/2/priority/5", "iconUrl"=>"http://localhost:2990/jira/images/icons/priority_trivial.gif", "name"=>"Trivial", "id"=>"5"}]}}
|
290
|
+
field = Jirarest2Field::HashField.new("priority","Priority",{:required => false, :createmeta => fstruct["priority"]})
|
291
|
+
allowed_v = ["Blocker", "Critical", "Major", "Minor", "Trivial"]
|
292
|
+
assert_equal "priority", field.id
|
293
|
+
assert_equal "Priority", field.name
|
294
|
+
assert_equal false, field.readonly
|
295
|
+
assert_equal "name", field.key
|
296
|
+
assert_equal allowed_v, field.allowed_values
|
297
|
+
end
|
298
|
+
def test_parse_value_priority
|
299
|
+
field = Jirarest2Field::HashField.new("priority","Priority",{:required => false, :key => "name"})
|
300
|
+
field.parse_value({"self"=>"http://localhost:2990/jira/rest/api/2/priority/4", "iconUrl"=>"http://localhost:2990/jira/images/icons/priority_minor.gif", "name"=>"Minor", "id"=>"4"})
|
301
|
+
assert_equal "Minor",field.value
|
302
|
+
toj = {"priority"=>{"name"=>"Minor"}}
|
303
|
+
assert_equal toj, field.to_j
|
304
|
+
end
|
305
|
+
|
306
|
+
def test_customfield_10001 # datetime -> DateTimeField
|
307
|
+
fstruct = {"customfield_10001" => {"required"=>false, "schema"=>{"type"=>"datetime", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:datetime", "customId"=>10001}, "name"=>"Date Time Field", "operations"=>["set"]}}
|
308
|
+
field = Jirarest2Field::DateTimeField.new("customfield_10001","Date Time Field",{:required => false, :createmeta => fstruct["customfield_10001"]})
|
309
|
+
allowed_v = []
|
310
|
+
assert_equal "customfield_10001", field.id
|
311
|
+
assert_equal "Date Time Field", field.name
|
312
|
+
assert_equal false, field.readonly
|
313
|
+
assert_raises(NoMethodError) { field.key }
|
314
|
+
assert_equal allowed_v, field.allowed_values
|
315
|
+
end
|
316
|
+
def test_parse_value_customfield_10001
|
317
|
+
field = Jirarest2Field::DateTimeField.new("customfield_10001","Date Time Field",{:required => false})
|
318
|
+
field.parse_value("2012-08-22T19:08:00.000+0200")
|
319
|
+
assert_equal DateTime.parse("2012-08-22T19:08:00.000+0200"),field.value(true)
|
320
|
+
toj = {"customfield_10001"=>"2012-08-22T19:08:00.000+0200"}
|
321
|
+
assert_equal toj, field.to_j
|
322
|
+
end
|
323
|
+
|
324
|
+
def test_duedate # date -> DateField
|
325
|
+
fstruct = {"duedate" => {"required"=>false, "schema"=>{"type"=>"date", "system"=>"duedate"}, "name"=>"Due Date", "operations"=>["set"]}}
|
326
|
+
field = Jirarest2Field::DateField.new("duedate","Due Date",{:required => false, :createmeta => fstruct["duedate"]})
|
327
|
+
allowed_v = []
|
328
|
+
assert_equal "duedate", field.id
|
329
|
+
assert_equal "Due Date", field.name
|
330
|
+
assert_equal false, field.readonly
|
331
|
+
assert_raises(NoMethodError) { field.key }
|
332
|
+
assert_equal allowed_v, field.allowed_values
|
333
|
+
end
|
334
|
+
def test_parse_value_duedate
|
335
|
+
field = Jirarest2Field::DateField.new("duedate","Due Date",{:required => false})
|
336
|
+
field.parse_value("2012-08-29")
|
337
|
+
assert_equal Date.parse("2012-08-29"),field.value(true)
|
338
|
+
toj = {"duedate"=>"2012-08-29"}
|
339
|
+
assert_equal toj, field.to_j
|
340
|
+
end
|
341
|
+
|
342
|
+
def test_customfield_10002 # datepicker -> DateField
|
343
|
+
fstruct = {"customfield_10002" => {"required"=>false, "schema"=>{"type"=>"date", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:datepicker", "customId"=>10002}, "name"=>"Date Picker", "operations"=>["set"]}}
|
344
|
+
field = Jirarest2Field::DateField.new("customfield_10002","Date Picker",{:required => false, :createmeta => fstruct["customfield_10002"]})
|
345
|
+
allowed_v = []
|
346
|
+
assert_equal "customfield_10002", field.id
|
347
|
+
assert_equal "Date Picker", field.name
|
348
|
+
assert_equal false, field.readonly
|
349
|
+
assert_raises(NoMethodError) { field.key }
|
350
|
+
assert_equal allowed_v, field.allowed_values
|
351
|
+
end
|
352
|
+
def test_parse_value_customfield_10002
|
353
|
+
field = Jirarest2Field::DateField.new("customfield_10002","Date Picker",{:required => false})
|
354
|
+
field.parse_value("2012-08-14")
|
355
|
+
assert_equal Date.parse("2012-08-14"),field.value(true)
|
356
|
+
toj = {"customfield_10002"=>"2012-08-14"}
|
357
|
+
assert_equal toj, field.to_j
|
358
|
+
end
|
359
|
+
|
360
|
+
def test_customfield_10310 # jobcheckbox -> TextField
|
361
|
+
fstruct = {"customfield_10310" => {"required"=>false, "schema"=>{"type"=>"string", "custom"=>"com.atlassian.jirafisheyeplugin:jobcheckbox", "customId"=>10310}, "name"=>"Job Checkbox", "operations"=>["set"]}}
|
362
|
+
field = Jirarest2Field::TextField.new("customfield_10310","Job Checkbox",{:required => false, :createmeta => fstruct["customfield_10310"]})
|
363
|
+
allowed_v = []
|
364
|
+
assert_equal "customfield_10310", field.id
|
365
|
+
assert_equal "Job Checkbox", field.name
|
366
|
+
assert_equal false, field.readonly
|
367
|
+
assert_raises(NoMethodError) { field.key }
|
368
|
+
assert_equal allowed_v, field.allowed_values
|
369
|
+
end
|
370
|
+
def test_parse_value_customfield_10310
|
371
|
+
field = Jirarest2Field::TextField.new("customfield_10310","Job Checkbox",{:required => false})
|
372
|
+
field.parse_value("false")
|
373
|
+
assert_equal "false",field.value
|
374
|
+
toj = {"customfield_10310"=>"false"}
|
375
|
+
assert_equal toj, field.to_j
|
376
|
+
end
|
377
|
+
|
378
|
+
def test_customfield_10003 # textarea -> TextField
|
379
|
+
fstruct = {"customfield_10003" => {"required"=>false, "schema"=>{"type"=>"string", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:textarea", "customId"=>10003}, "name"=>"Großes Text", "operations"=>["set"]}}
|
380
|
+
field = Jirarest2Field::TextField.new("customfield_10003","Großes Text",{:required => false, :createmeta => fstruct["customfield_10003"]})
|
381
|
+
allowed_v = []
|
382
|
+
assert_equal "customfield_10003", field.id
|
383
|
+
assert_equal "Großes Text", field.name
|
384
|
+
assert_equal false, field.readonly
|
385
|
+
assert_raises(NoMethodError) { field.key }
|
386
|
+
assert_equal allowed_v, field.allowed_values
|
387
|
+
end
|
388
|
+
def test_parse_value_customfield_10003
|
389
|
+
field = Jirarest2Field::TextField.new("customfield_10003","Großes Text",{:required => false})
|
390
|
+
field.parse_value("Big Text?")
|
391
|
+
assert_equal "Big Text?",field.value
|
392
|
+
toj = {"customfield_10003"=>"Big Text?"}
|
393
|
+
assert_equal toj, field.to_j
|
394
|
+
end
|
395
|
+
|
396
|
+
def test_customfield_10311 # float -> NumberField
|
397
|
+
fstruct = {"customfield_10311" => {"required"=>false, "schema"=>{"type"=>"number", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:float", "customId"=>10311}, "name"=>"Numbers no", "operations"=>["set"]}}
|
398
|
+
field = Jirarest2Field::NumberField.new("customfield_10311","Numbers no",{:required => false, :createmeta => fstruct["customfield_10311"]})
|
399
|
+
allowed_v = []
|
400
|
+
assert_equal "customfield_10311", field.id
|
401
|
+
assert_equal "Numbers no", field.name
|
402
|
+
assert_equal false, field.readonly
|
403
|
+
assert_raises(NoMethodError) { field.key }
|
404
|
+
assert_equal allowed_v, field.allowed_values
|
405
|
+
end
|
406
|
+
def test_parse_value_customfield_10311
|
407
|
+
field = Jirarest2Field::NumberField.new("customfield_10311","Numbers no",{:required => false})
|
408
|
+
field.parse_value(14.0)
|
409
|
+
assert_equal 14.0,field.value
|
410
|
+
toj = {"customfield_10311"=>14.0}
|
411
|
+
assert_equal toj, field.to_j
|
412
|
+
end
|
413
|
+
|
414
|
+
def test_customfield_10004 # multicheckboxes -> MultiHashField
|
415
|
+
fstruct = {"customfield_10004" => {"required"=>false, "schema"=>{"type"=>"array", "items"=>"string", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes", "customId"=>10004}, "name"=>"Multi Checkboxes", "operations"=>["add", "set", "remove"], "allowedValues"=>[{"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10019", "value"=>"Göthe", "id"=>"10019"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10020", "value"=>"Schiller", "id"=>"10020"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10021", "value"=>"Heine", "id"=>"10021"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10022", "value"=>"Kafka", "id"=>"10022"}]}}
|
416
|
+
field = Jirarest2Field::MultiHashField.new("customfield_10004","Multi Checkboxes",{:required => false, :createmeta => fstruct["customfield_10004"]})
|
417
|
+
allowed_v = ["Göthe", "Schiller", "Heine", "Kafka"]
|
418
|
+
assert_equal "customfield_10004", field.id
|
419
|
+
assert_equal "Multi Checkboxes", field.name
|
420
|
+
assert_equal false, field.readonly
|
421
|
+
assert_equal "value", field.key
|
422
|
+
assert_equal allowed_v, field.allowed_values
|
423
|
+
end
|
424
|
+
def test_parse_value_customfield_10004
|
425
|
+
assert_raises(Jirarest2::HashKeyMissingException){Jirarest2Field::MultiHashField.new("customfield_10004","Multi Checkboxes",{:required => false})}
|
426
|
+
field = Jirarest2Field::MultiHashField.new("customfield_10004","Multi Checkboxes",{:required => false, :key => "value"})
|
427
|
+
field.parse_value([{"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10021", "value"=>"Heine", "id"=>"10021"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10019", "value"=>"Göthe", "id"=>"10019"}])
|
428
|
+
assert_equal ["Heine","Göthe"],field.value
|
429
|
+
toj = {"customfield_10004" => [{"value" => "Heine"},{"value" => "Göthe"}]}
|
430
|
+
assert_equal toj, field.to_j
|
431
|
+
end
|
432
|
+
|
433
|
+
def test_customfield_10312 # float -> NumberField
|
434
|
+
fstruct = {"customfield_10312" => {"required"=>false, "schema"=>{"type"=>"number", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:float", "customId"=>10312}, "name"=>"Numbers range", "operations"=>["set"]}}
|
435
|
+
field = Jirarest2Field::NumberField.new("customfield_10312","Numbers range",{:required => false, :createmeta => fstruct["customfield_10312"]})
|
436
|
+
allowed_v = []
|
437
|
+
assert_equal "customfield_10312", field.id
|
438
|
+
assert_equal "Numbers range", field.name
|
439
|
+
assert_equal false, field.readonly
|
440
|
+
assert_raises(NoMethodError) { field.key }
|
441
|
+
assert_equal allowed_v, field.allowed_values
|
442
|
+
end
|
443
|
+
def test_parse_value_customfield_10312
|
444
|
+
field = Jirarest2Field::NumberField.new("customfield_10312","Numbers range",{:required => false})
|
445
|
+
field.parse_value(23.0)
|
446
|
+
assert_equal 23.0,field.value
|
447
|
+
toj = {"customfield_10312"=>23.0}
|
448
|
+
assert_equal toj, field.to_j
|
449
|
+
end
|
450
|
+
|
451
|
+
def test_customfield_10000 # cascadingselect -> CascadingField
|
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
|
+
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"]}]
|
455
|
+
assert_equal "customfield_10000", field.id
|
456
|
+
assert_equal "Cascading Select Test", field.name
|
457
|
+
assert_equal false, field.readonly
|
458
|
+
assert_equal "value", field.key
|
459
|
+
assert_equal allowed_v, field.allowed_values
|
460
|
+
end
|
461
|
+
def test_parse_value_customfield_10000
|
462
|
+
field = Jirarest2Field::CascadingField.new("customfield_10000","Cascading Select Test",{:required => false})
|
463
|
+
field.parse_value({"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10000", "value"=>"English", "id"=>"10000", "child"=>{"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10003", "value"=>"One", "id"=>"10003"}})
|
464
|
+
assert_equal ["English","One"],field.value
|
465
|
+
toj = {"customfield_10000"=>{"value"=>"English", "child"=>{"value"=>"One"}}}
|
466
|
+
assert_equal toj, field.to_j
|
467
|
+
end
|
468
|
+
|
469
|
+
def test_customfield_10102 # textfield -> TextField
|
470
|
+
fstruct = {"customfield_10102" => {"required"=>false, "schema"=>{"type"=>"string", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:textfield", "customId"=>10102}, "name"=>"projects", "operations"=>["set"]}}
|
471
|
+
field = Jirarest2Field::TextField.new("customfield_10102","projects",{:required => false, :createmeta => fstruct["customfield_10102"]})
|
472
|
+
allowed_v = []
|
473
|
+
assert_equal "customfield_10102", field.id
|
474
|
+
assert_equal "projects", field.name
|
475
|
+
assert_equal false, field.readonly
|
476
|
+
assert_raises(NoMethodError) { field.key }
|
477
|
+
assert_equal allowed_v, field.allowed_values
|
478
|
+
end
|
479
|
+
def test_parse_value_customfield_10102
|
480
|
+
field = Jirarest2Field::TextField.new("customfield_10102","projects",{:required => false})
|
481
|
+
field.parse_value("Muhahahaha")
|
482
|
+
assert_equal "Muhahahaha",field.value
|
483
|
+
toj = {"customfield_10102"=>"Muhahahaha"}
|
484
|
+
assert_equal toj, field.to_j
|
485
|
+
end
|
486
|
+
|
487
|
+
def test_customfield_10101 # textfield -> TextField
|
488
|
+
fstruct = {"customfield_10101" => {"required"=>false, "schema"=>{"type"=>"string", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:textfield", "customId"=>10101}, "name"=>"Issue Type", "operations"=>["set"]}}
|
489
|
+
field = Jirarest2Field::TextField.new("customfield_10101","Issue Type",{:required => false, :createmeta => fstruct["customfield_10101"]})
|
490
|
+
allowed_v = []
|
491
|
+
assert_equal "customfield_10101", field.id
|
492
|
+
assert_equal "Issue Type", field.name
|
493
|
+
assert_equal false, field.readonly
|
494
|
+
assert_raises(NoMethodError) { field.key }
|
495
|
+
assert_equal allowed_v, field.allowed_values
|
496
|
+
end
|
497
|
+
def test_parse_value_customfield_10101
|
498
|
+
field = Jirarest2Field::TextField.new("customfield_10101","Issue Type",{:required => false})
|
499
|
+
field.parse_value("Works")
|
500
|
+
assert_equal "Works",field.value
|
501
|
+
toj = {"customfield_10101"=>"Works"}
|
502
|
+
assert_equal toj, field.to_j
|
503
|
+
end
|
504
|
+
|
505
|
+
def test_customfield_10100 # textfield -> TextField
|
506
|
+
fstruct = {"customfield_10100" => {"required"=>false, "schema"=>{"type"=>"string", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:textfield", "customId"=>10100}, "name"=>"issuetype", "operations"=>["set"]}}
|
507
|
+
field = Jirarest2Field::TextField.new("customfield_10100","issuetype",{:required => false, :createmeta => fstruct["customfield_10100"]})
|
508
|
+
allowed_v = []
|
509
|
+
assert_equal "customfield_10100", field.id
|
510
|
+
assert_equal "issuetype", field.name
|
511
|
+
assert_equal false, field.readonly
|
512
|
+
assert_raises(NoMethodError) { field.key }
|
513
|
+
assert_equal allowed_v, field.allowed_values
|
514
|
+
end
|
515
|
+
def test_parse_value_customfield_10100
|
516
|
+
field = Jirarest2Field::TextField.new("customfield_10100","issuetype",{:required => false})
|
517
|
+
field.parse_value("Works again")
|
518
|
+
assert_equal "Works again",field.value
|
519
|
+
toj = {"customfield_10100"=>"Works again"}
|
520
|
+
assert_equal toj, field.to_j
|
521
|
+
end
|
522
|
+
|
523
|
+
def test_customfield_10006 # select -> HashField
|
524
|
+
fstruct = {"customfield_10006" => {"required"=>false, "schema"=>{"type"=>"string", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:select", "customId"=>10006}, "name"=>"List select", "operations"=>["set"], "allowedValues"=>[{"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10015", "value"=>"Räuber", "id"=>"10015"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10016", "value"=>"Kabale und Liebe", "id"=>"10016"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10017", "value"=>"Faust", "id"=>"10017"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10018", "value"=>"Landleben", "id"=>"10018"}]}}
|
525
|
+
field = Jirarest2Field::HashField.new("customfield_10006","List select",{:required => false, :createmeta => fstruct["customfield_10006"]})
|
526
|
+
allowed_v = ["Räuber", "Kabale und Liebe", "Faust", "Landleben"]
|
527
|
+
assert_equal "customfield_10006", field.id
|
528
|
+
assert_equal "List select", field.name
|
529
|
+
assert_equal false, field.readonly
|
530
|
+
assert_equal "value", field.key
|
531
|
+
assert_equal allowed_v, field.allowed_values
|
532
|
+
end
|
533
|
+
def test_parse_value_customfield_10006
|
534
|
+
field = Jirarest2Field::HashField.new("customfield_10006","List select",{:required => false, :key => "value"})
|
535
|
+
field.parse_value({"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10017", "value"=>"Faust", "id"=>"10017"})
|
536
|
+
assert_equal "Faust",field.value
|
537
|
+
toj = {"customfield_10006" => {"value" => "Faust"}}
|
538
|
+
assert_equal toj, field.to_j
|
539
|
+
end
|
540
|
+
|
541
|
+
def test_customfield_10005 # multiselect -> MultiHashField
|
542
|
+
fstruct = {"customfield_10005" => {"required"=>false, "schema"=>{"type"=>"array", "items"=>"string", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:multiselect", "customId"=>10005}, "name"=>"Multi Select", "operations"=>["add", "set", "remove"], "allowedValues"=>[{"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10023", "value"=>"Glocke", "id"=>"10023"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10024", "value"=>"Kabale und Liebe", "id"=>"10024"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10025", "value"=>"Schiller", "id"=>"10025"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10026", "value"=>"Göthe", "id"=>"10026"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10027", "value"=>"Faust", "id"=>"10027"}]}}
|
543
|
+
field = Jirarest2Field::MultiHashField.new("customfield_10005","Multi Select",{:required => false, :createmeta => fstruct["customfield_10005"]})
|
544
|
+
allowed_v = ["Glocke", "Kabale und Liebe", "Schiller", "Göthe", "Faust"]
|
545
|
+
assert_equal "customfield_10005", field.id
|
546
|
+
assert_equal "Multi Select", field.name
|
547
|
+
assert_equal false, field.readonly
|
548
|
+
assert_equal "value", field.key
|
549
|
+
assert_equal allowed_v, field.allowed_values
|
550
|
+
end
|
551
|
+
def test_parse_value_customfield_10005
|
552
|
+
field = Jirarest2Field::MultiHashField.new("customfield_10005","Multi Select",{:required => false, :key => "value"})
|
553
|
+
field.parse_value([{"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10025", "value"=>"Schiller", "id"=>"10025"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10026", "value"=>"Göthe", "id"=>"10026"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10024", "value"=>"Kabale und Liebe", "id"=>"10024"}])
|
554
|
+
assert_equal ["Schiller","Göthe","Kabale und Liebe"],field.value
|
555
|
+
toj = {"customfield_10005" => [{"value" => "Schiller"},{"value" => "Göthe"},{"value" => "Kabale und Liebe"}]}
|
556
|
+
assert_equal toj, field.to_j
|
557
|
+
end
|
558
|
+
|
559
|
+
def test_labels # labels -> MultiStringField
|
560
|
+
fstruct = {"labels" => {"required"=>false, "schema"=>{"type"=>"array", "items"=>"string", "system"=>"labels"}, "name"=>"Labels", "autoCompleteUrl"=>"http://localhost:2990/jira/rest/api/1.0/labels/suggest?query=", "operations"=>["add", "set", "remove"]}}
|
561
|
+
field = Jirarest2Field::MultiStringField.new("labels","Labels",{:required => false, :createmeta => fstruct["labels"]})
|
562
|
+
allowed_v = []
|
563
|
+
assert_equal "labels", field.id
|
564
|
+
assert_equal "Labels", field.name
|
565
|
+
assert_equal false, field.readonly
|
566
|
+
assert_raises(NoMethodError) { field.key }
|
567
|
+
assert_equal allowed_v, field.allowed_values
|
568
|
+
end
|
569
|
+
def test_parse_value_labels
|
570
|
+
field = Jirarest2Field::MultiStringField.new("labels","Labels",{:required => false})
|
571
|
+
field.parse_value(["We", "do", "don't", "labels", "love", "we?"])
|
572
|
+
assert_equal ["We", "do", "don't", "labels", "love", "we?"],field.value
|
573
|
+
toj = {"labels"=>["We", "do", "don't", "labels", "love", "we?"]}
|
574
|
+
assert_equal toj, field.to_j
|
575
|
+
end
|
576
|
+
|
577
|
+
def test_customfield_10315 # userPicker -> UserField
|
578
|
+
fstruct = {"customfield_10315" => {"required"=>false, "schema"=>{"type"=>"user", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:userpicker", "customId"=>10315}, "name"=>"User Picker User", "autoCompleteUrl"=>"http://localhost:2990/jira/rest/api/1.0/users/picker?fieldName=customfield_10315&query=", "operations"=>["set"]}}
|
579
|
+
field = Jirarest2Field::UserField.new("customfield_10315","User Picker User",{:required => false, :createmeta => fstruct["customfield_10315"]})
|
580
|
+
allowed_v = []
|
581
|
+
assert_equal "customfield_10315", field.id
|
582
|
+
assert_equal "User Picker User", field.name
|
583
|
+
assert_equal false, field.readonly
|
584
|
+
assert_equal "name", field.key
|
585
|
+
assert_equal allowed_v, field.allowed_values
|
586
|
+
end
|
587
|
+
def test_parse_value_customfield_10315
|
588
|
+
field = Jirarest2Field::UserField.new("customfield_10315","User Picker User",{:required => false, :key => "name"})
|
589
|
+
field.parse_value({"self"=>"http://localhost:2990/jira/rest/api/2/user?username=test", "name"=>"test", "emailAddress"=>"jira-test@madbit.de", "avatarUrls"=>{"16x16"=>"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122", "48x48"=>"http://localhost:2990/jira/secure/useravatar?avatarId=10122"}, "displayName"=>"Test User", "active"=>true})
|
590
|
+
assert_equal "test",field.value
|
591
|
+
toj = {"customfield_10315" => {"name" => "test"}}
|
592
|
+
assert_equal toj, field.to_j
|
593
|
+
end
|
594
|
+
|
595
|
+
def test_assignee # assignee -> UserField
|
596
|
+
fstruct = {"assignee" => {"required"=>false, "schema"=>{"type"=>"user", "system"=>"assignee"}, "name"=>"Assignee", "autoCompleteUrl"=>"http://localhost:2990/jira/rest/api/latest/user/assignable/search?issueKey=null&username=", "operations"=>["set"]}}
|
597
|
+
field = Jirarest2Field::UserField.new("assignee","Assignee",{:required => false, :createmeta => fstruct["assignee"]})
|
598
|
+
allowed_v = []
|
599
|
+
assert_equal "assignee", field.id
|
600
|
+
assert_equal "Assignee", field.name
|
601
|
+
assert_equal false, field.readonly
|
602
|
+
assert_equal "name", field.key
|
603
|
+
assert_equal allowed_v, field.allowed_values
|
604
|
+
end
|
605
|
+
def test_parse_value_assignee
|
606
|
+
field = Jirarest2Field::UserField.new("assignee","Assignee",{:required => false, :key => "name"})
|
607
|
+
field.parse_value(nil)
|
608
|
+
assert_equal nil,field.value
|
609
|
+
toj = nil
|
610
|
+
assert_equal toj, field.to_j
|
611
|
+
# @todo See if there should not be a check with a value as well
|
612
|
+
end
|
613
|
+
|
614
|
+
def test_customfield_10316 # userpicker -> UserField
|
615
|
+
fstruct = {"customfield_10316" => {"required"=>false, "schema"=>{"type"=>"user", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:userpicker", "customId"=>10316}, "name"=>"User Picker U+G", "autoCompleteUrl"=>"http://localhost:2990/jira/rest/api/1.0/users/picker?fieldName=customfield_10316&query=", "operations"=>["set"]}}
|
616
|
+
field = Jirarest2Field::UserField.new("customfield_10316","User Picker U+G",{:required => false, :createmeta => fstruct["customfield_10316"]})
|
617
|
+
allowed_v = []
|
618
|
+
assert_equal "customfield_10316", field.id
|
619
|
+
assert_equal "User Picker U+G", field.name
|
620
|
+
assert_equal false, field.readonly
|
621
|
+
assert_equal "name", field.key
|
622
|
+
assert_equal allowed_v, field.allowed_values
|
623
|
+
end
|
624
|
+
def test_parse_value_customfield_10316
|
625
|
+
field = Jirarest2Field::UserField.new("customfield_10316","User Picker U+G",{:required => false, :key => "name"})
|
626
|
+
field.parse_value({"self"=>"http://localhost:2990/jira/rest/api/2/user?username=test", "name"=>"test", "emailAddress"=>"jira-test@madbit.de", "avatarUrls"=>{"16x16"=>"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122", "48x48"=>"http://localhost:2990/jira/secure/useravatar?avatarId=10122"}, "displayName"=>"Test User", "active"=>true})
|
627
|
+
assert_equal "test",field.value
|
628
|
+
toj = {"customfield_10316" => {"name" => "test"}}
|
629
|
+
assert_equal toj, field.to_j
|
630
|
+
end
|
631
|
+
|
632
|
+
def test_customfield_10313 # radiobuttons -> HashField
|
633
|
+
fstruct = {"customfield_10313" => {"required"=>false, "schema"=>{"type"=>"string", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons", "customId"=>10313}, "name"=>"Radios", "operations"=>["set"], "allowedValues"=>[{"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10100", "value"=>"Books", "id"=>"10100"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10101", "value"=>"EBooks", "id"=>"10101"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10102", "value"=>"Newspaper", "id"=>"10102"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10103", "value"=>"Websites", "id"=>"10103"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10104", "value"=>"Magazines", "id"=>"10104"}]}}
|
634
|
+
field = Jirarest2Field::HashField.new("customfield_10313","Radios",{:required => false, :createmeta => fstruct["customfield_10313"]})
|
635
|
+
allowed_v = ["Books", "EBooks", "Newspaper", "Websites", "Magazines"]
|
636
|
+
assert_equal "customfield_10313", field.id
|
637
|
+
assert_equal "Radios", field.name
|
638
|
+
assert_equal false, field.readonly
|
639
|
+
assert_equal "value", field.key
|
640
|
+
assert_equal allowed_v, field.allowed_values
|
641
|
+
end
|
642
|
+
def test_parse_value_customfield_10313
|
643
|
+
field = Jirarest2Field::HashField.new("customfield_10313","Radios",{:required => false, :key => "value"})
|
644
|
+
field.parse_value( {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10102", "value"=>"Newspaper", "id"=>"10102"})
|
645
|
+
assert_equal "Newspaper",field.value
|
646
|
+
toj = {"customfield_10313"=>{"value"=>"Newspaper"}}
|
647
|
+
assert_equal toj, field.to_j
|
648
|
+
end
|
649
|
+
|
650
|
+
def test_customfield_10314 # select -> HashField
|
651
|
+
fstruct = {"customfield_10314" => {"required"=>false, "schema"=>{"type"=>"string", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:select", "customId"=>10314}, "name"=>"Select List Multi", "operations"=>["set"], "allowedValues"=>[{"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10105", "value"=>"Car", "id"=>"10105"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10106", "value"=>"Train", "id"=>"10106"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10107", "value"=>"Subway", "id"=>"10107"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10108", "value"=>"Underground", "id"=>"10108"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10109", "value"=>"Plane", "id"=>"10109"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10110", "value"=>"Ship", "id"=>"10110"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10111", "value"=>"Hovercraft", "id"=>"10111"}, {"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10112", "value"=>"Foot", "id"=>"10112"}]}}
|
652
|
+
field = Jirarest2Field::HashField.new("customfield_10314","Select List Multi",{:required => false, :createmeta => fstruct["customfield_10314"]})
|
653
|
+
allowed_v = ["Car", "Train", "Subway", "Underground", "Plane", "Ship", "Hovercraft", "Foot"]
|
654
|
+
assert_equal "customfield_10314", field.id
|
655
|
+
assert_equal "Select List Multi", field.name
|
656
|
+
assert_equal false, field.readonly
|
657
|
+
assert_equal "value", field.key
|
658
|
+
assert_equal allowed_v, field.allowed_values
|
659
|
+
end
|
660
|
+
def test_parse_value_customfield_10314
|
661
|
+
field = Jirarest2Field::HashField.new("customfield_10314","Select List Multi",{:required => false, :key => "value"})
|
662
|
+
field.parse_value({"self"=>"http://localhost:2990/jira/rest/api/2/customFieldOption/10108", "value"=>"Underground", "id"=>"10108"})
|
663
|
+
assert_equal "Underground",field.value
|
664
|
+
toj = {"customfield_10314"=>{"value"=>"Underground"}}
|
665
|
+
assert_equal toj, field.to_j
|
666
|
+
end
|
667
|
+
|
668
|
+
def test_attachment # attachment -> TextField
|
669
|
+
fstruct = {"attachment" => {"required"=>false, "schema"=>{"type"=>"array", "items"=>"attachment", "system"=>"attachment"}, "name"=>"Attachment", "operations"=>[]}}
|
670
|
+
field = Jirarest2Field::MultiStringField.new("attachment","Attachment",{:required => false, :createmeta => fstruct["attachment"]})
|
671
|
+
allowed_v = []
|
672
|
+
assert_equal "attachment", field.id
|
673
|
+
assert_equal "Attachment", field.name
|
674
|
+
assert_equal true, field.readonly
|
675
|
+
assert_raises(NoMethodError) { field.key }
|
676
|
+
assert_equal allowed_v, field.allowed_values
|
677
|
+
end
|
678
|
+
def test_parse_value_attachment
|
679
|
+
field = Jirarest2Field::MultiStringField.new("attachment","Attachment",{:required => false})
|
680
|
+
field.parse_value([])
|
681
|
+
assert_equal [],field.value
|
682
|
+
# @todo test to_j
|
683
|
+
end
|
684
|
+
|
685
|
+
def test_customfield_10200 #multiuserpicker -> MultiUserField
|
686
|
+
fstruct = {"customfield_10200" => {"required"=>false, "schema"=>{"type"=>"array", "items"=>"user", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:multiuserpicker", "customId"=>10200}, "name"=>"Multi User", "autoCompleteUrl"=>"http://localhost:2990/jira/rest/api/1.0/users/picker?fieldName=customfield_10200&query=", "operations"=>["add", "set", "remove"]}}
|
687
|
+
field = Jirarest2Field::MultiUserField.new("customfield_10200","Multi User",{:required => false, :createmeta => fstruct["customfield_10200"]})
|
688
|
+
allowed_v = []
|
689
|
+
assert_equal "customfield_10200", field.id
|
690
|
+
assert_equal "Multi User", field.name
|
691
|
+
assert_equal false, field.readonly
|
692
|
+
assert_equal "name", field.key
|
693
|
+
assert_equal allowed_v, field.allowed_values
|
694
|
+
end
|
695
|
+
def test_parse_value_customfield_10200
|
696
|
+
field = Jirarest2Field::MultiUserField.new("customfield_10200","Multi User",{:required => false, :key => "name"})
|
697
|
+
field.parse_value( [{"self"=>"http://localhost:2990/jira/rest/api/2/user?username=admin", "name"=>"admin", "emailAddress"=>"admin@example.com", "avatarUrls"=>{"16x16"=>"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122", "48x48"=>"http://localhost:2990/jira/secure/useravatar?avatarId=10122"}, "displayName"=>"admin", "active"=>true}, {"self"=>"http://localhost:2990/jira/rest/api/2/user?username=test", "name"=>"test", "emailAddress"=>"jira-test@madbit.de", "avatarUrls"=>{"16x16"=>"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122", "48x48"=>"http://localhost:2990/jira/secure/useravatar?avatarId=10122"}, "displayName"=>"Test User", "active"=>true}])
|
698
|
+
assert_equal ["admin","test"],field.value
|
699
|
+
toj = {"customfield_10200" => [{"name" => "admin"},{"name" => "test"}]}
|
700
|
+
assert_equal toj, field.to_j
|
701
|
+
end
|
702
|
+
|
703
|
+
def test_project # project -> ProjectField
|
704
|
+
fstruct = {"project" => {"required"=>true, "schema"=>{"type"=>"project", "system"=>"project"}, "autoCompleteUrl"=>"Project", "operations"=>["set"], "allowedValues"=>[{"self"=>"http://localhost:2990/jira/rest/api/2/project/MFTP", "id"=>"10000", "key"=>"MFTP", "name"=>"My first Test Project", "avatarUrls"=>{"16x16"=>"http://localhost:2990/jira/secure/projectavatar?size=small&pid=10000&avatarId=10011", "48x48"=>"http://localhost:2990/jira/secure/projectavatar?pid=10000&avatarId=10011"}}]}}
|
705
|
+
field = Jirarest2Field::ProjectField.new("project","",{:required => false, :createmeta => fstruct["project"]})
|
706
|
+
allowed_v = ["MFTP"] # TODO
|
707
|
+
assert_equal "project", field.id
|
708
|
+
assert_equal "", field.name
|
709
|
+
assert_equal false, field.readonly
|
710
|
+
assert_equal "key", field.key
|
711
|
+
assert_equal "MFTP", field.value
|
712
|
+
assert_equal allowed_v, field.allowed_values
|
713
|
+
end
|
714
|
+
def test_parse_value_project
|
715
|
+
field = Jirarest2Field::ProjectField.new("project","",{:required => false, :key => "key"})
|
716
|
+
field.parse_value({"self"=>"http://localhost:2990/jira/rest/api/2/project/MFTP", "id"=>"10000", "key"=>"MFTP", "name"=>"My first Test Project", "avatarUrls"=>{"16x16"=>"http://localhost:2990/jira/secure/projectavatar?size=small&pid=10000&avatarId=10011", "48x48"=>"http://localhost:2990/jira/secure/projectavatar?pid=10000&avatarId=10011"}})
|
717
|
+
assert_equal "MFTP",field.value
|
718
|
+
toj = {"project"=>{"key"=>"MFTP"}}
|
719
|
+
assert_equal toj, field.to_j
|
720
|
+
end
|
721
|
+
|
722
|
+
def test_versions # version -> MultiVersionField
|
723
|
+
fstruct = {"versions" => {"required"=>false, "schema"=>{"type"=>"array", "items"=>"version", "system"=>"versions"}, "name"=>"Affects Version/s", "operations"=>["set", "add", "remove"], "allowedValues"=>[{"self"=>"http://localhost:2990/jira/rest/api/2/version/10000", "id"=>"10000", "description"=>"Version 0.1 dooh", "name"=>"0.1", "archived"=>false, "released"=>false, "releaseDate"=>"2012-07-01", "overdue"=>true, "userReleaseDate"=>"01/Jul/12"}, {"self"=>"http://localhost:2990/jira/rest/api/2/version/10001", "id"=>"10001", "description"=>"And now v0.2", "name"=>"0.2", "archived"=>false, "released"=>false, "releaseDate"=>"2012-08-01", "overdue"=>true, "userReleaseDate"=>"01/Aug/12"}, {"self"=>"http://localhost:2990/jira/rest/api/2/version/10002", "id"=>"10002", "description"=>"Version 0.3", "name"=>"0.3", "archived"=>false, "released"=>false, "releaseDate"=>"2012-08-31", "overdue"=>false, "userReleaseDate"=>"31/Aug/12"}]}}
|
724
|
+
field = Jirarest2Field::MultiVersionField.new("versions","Affects Version/s",{:required => false, :createmeta => fstruct["versions"]})
|
725
|
+
allowed_v = ["0.1","0.2","0.3"]
|
726
|
+
assert_equal "versions", field.id
|
727
|
+
assert_equal "Affects Version/s", field.name
|
728
|
+
assert_equal false, field.readonly
|
729
|
+
assert_equal "name", field.key
|
730
|
+
assert_equal allowed_v, field.allowed_values
|
731
|
+
end
|
732
|
+
def test_parse_value_versions
|
733
|
+
assert_raises(Jirarest2::HashKeyMissingException){Jirarest2Field::MultiVersionField.new("versions","Affects Version/s",{:required => false})}
|
734
|
+
field = Jirarest2Field::MultiVersionField.new("versions","Affects Version/s",{:required => false, :key => "name"})
|
735
|
+
field.parse_value([{"self"=>"http://localhost:2990/jira/rest/api/2/version/10001", "id"=>"10001", "description"=>"And now v0.2", "name"=>"0.2", "archived"=>false, "released"=>false, "releaseDate"=>"2012-08-01"}])
|
736
|
+
assert_equal ["0.2"],field.value
|
737
|
+
toj = { "versions" => [{"name" => "0.2"}]}
|
738
|
+
assert_equal toj, field.to_j
|
739
|
+
end
|
740
|
+
|
741
|
+
def test_environment #environment -> TextField
|
742
|
+
fstruct = {"environment" => {"required"=>false, "schema"=>{"type"=>"string", "system"=>"environment"}, "name"=>"Environment", "operations"=>["set"]}}
|
743
|
+
field = Jirarest2Field::TextField.new("environment","Environment",{:required => false, :createmeta => fstruct["environment"]})
|
744
|
+
allowed_v = []
|
745
|
+
assert_equal "environment", field.id
|
746
|
+
assert_equal "Environment", field.name
|
747
|
+
assert_equal false, field.readonly
|
748
|
+
assert_raises(NoMethodError) { field.key }
|
749
|
+
assert_equal allowed_v, field.allowed_values
|
750
|
+
end
|
751
|
+
def test_parse_value_environment
|
752
|
+
field = Jirarest2Field::TextField.new("environment","Environment",{:required => false})
|
753
|
+
field.parse_value("Environment? Doomed!")
|
754
|
+
assert_equal "Environment? Doomed!",field.value
|
755
|
+
toj = {"environment"=>"Environment? Doomed!"}
|
756
|
+
assert_equal toj, field.to_j
|
757
|
+
end
|
758
|
+
|
759
|
+
def test_customfield_10300 # grouppicker -> UserField
|
760
|
+
fstruct = {"customfield_10300" => {"required"=>false, "schema"=>{"type"=>"group", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:grouppicker", "customId"=>10300}, "name"=>"Pick Group", "operations"=>["set"]}}
|
761
|
+
field = Jirarest2Field::UserField.new("customfield_10300","Pick Group",{:required => false, :createmeta => fstruct["customfield_10300"]})
|
762
|
+
allowed_v = []
|
763
|
+
assert_equal "customfield_10300", field.id
|
764
|
+
assert_equal "Pick Group", field.name
|
765
|
+
assert_equal false, field.readonly
|
766
|
+
assert_equal "name", field.key
|
767
|
+
assert_equal allowed_v, field.allowed_values
|
768
|
+
end
|
769
|
+
def test_parse_value_customfield_10300
|
770
|
+
field = Jirarest2Field::UserField.new("customfield_10300","Pick Group",{:required => false, :key => "name"})
|
771
|
+
field.parse_value({"name"=>"jira-developers"})
|
772
|
+
assert_equal "jira-developers",field.value
|
773
|
+
toj = {"customfield_10300"=>{"name"=>"jira-developers"}}
|
774
|
+
assert_equal toj, field.to_j
|
775
|
+
end
|
776
|
+
|
777
|
+
def test_customfield_10301 # importid -> NumberField
|
778
|
+
fstruct = {"customfield_10301" => {"required"=>false, "schema"=>{"type"=>"number", "custom"=>"com.atlassian.jira.plugin.system.customfieldtypes:importid", "customId"=>10301}, "name"=>"Import ID Field no search", "operations"=>["set"]}}
|
779
|
+
field = Jirarest2Field::NumberField.new("customfield_10301","Import ID Field no search",{:required => false, :createmeta => fstruct["customfield_10301"]})
|
780
|
+
allowed_v = []
|
781
|
+
assert_equal "customfield_10301", field.id
|
782
|
+
assert_equal "Import ID Field no search", field.name
|
783
|
+
assert_equal false, field.readonly
|
784
|
+
assert_raises(NoMethodError) { field.key }
|
785
|
+
assert_equal allowed_v, field.allowed_values
|
786
|
+
end
|
787
|
+
def test_parse_value_customfield_10301
|
788
|
+
field = Jirarest2Field::NumberField.new("customfield_10301","Import ID Field no search",{:required => false})
|
789
|
+
field.parse_value(nil)
|
790
|
+
assert_equal nil,field.value
|
791
|
+
toj = nil
|
792
|
+
assert_equal toj, field.to_j
|
793
|
+
end
|
794
|
+
|
795
|
+
def test_components # components -> MultiHashField
|
796
|
+
fstruct = {"components" => {"required"=>false, "schema"=>{"type"=>"array", "items"=>"component", "system"=>"components"}, "name"=>"Component/s", "operations"=>["add", "set", "remove"], "allowedValues"=>[{"self"=>"http://localhost:2990/jira/rest/api/2/component/10000", "id"=>"10000", "name"=>"Signal1", "description"=>"A component "}, {"self"=>"http://localhost:2990/jira/rest/api/2/component/10001", "id"=>"10001", "name"=>"Sissi", "description"=>"Another Component"}]}}
|
797
|
+
field = Jirarest2Field::MultiHashField.new("components","Component/s",{:required => false, :createmeta => fstruct["components"]})
|
798
|
+
allowed_v = ["Signal1","Sissi"]
|
799
|
+
assert_equal "components", field.id
|
800
|
+
assert_equal "Component/s", field.name
|
801
|
+
assert_equal false, field.readonly
|
802
|
+
assert_equal "name", field.key
|
803
|
+
assert_equal allowed_v, field.allowed_values
|
804
|
+
end
|
805
|
+
def test_parse_value_components
|
806
|
+
field = Jirarest2Field::MultiHashField.new("components","Component/s",{:required => false, :key => "name"})
|
807
|
+
field.parse_value( [{"self"=>"http://localhost:2990/jira/rest/api/2/component/10001", "id"=>"10001", "name"=>"Sissi", "description"=>"Another Component"}])
|
808
|
+
assert_equal ["Sissi"],field.value
|
809
|
+
toj = {"components" => [{"name" => "Sissi"}]}
|
810
|
+
assert_equal toj, field.to_j
|
811
|
+
end
|
812
|
+
|
813
|
+
def test_allowedValues_empty
|
814
|
+
fstruct = {"allowed_empty" => {"required"=>false, "schema"=>{"type"=>"array", "items"=>"version", "system"=>"versions"}, "name"=>"Affects Version/s", "operations"=>["set", "add", "remove"], "allowedValues"=>[]}}
|
815
|
+
field = Jirarest2Field::MultiVersionField.new("allowed_empty","AllowedValues empty",{:required => false, :createmeta => fstruct["allowed_empty"]})
|
816
|
+
allowed_v = []
|
817
|
+
assert_equal allowed_v, field.allowed_values
|
818
|
+
end
|
819
|
+
|
820
|
+
end
|