jiralicious 0.4.3 → 0.5.0
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/.document +5 -5
- data/.gitignore +11 -11
- data/.rspec +1 -1
- data/.ruby-gemset +1 -1
- data/.travis.yml +10 -10
- data/Gemfile +4 -4
- data/LICENSE +22 -22
- data/README.md +99 -94
- data/Rakefile +16 -16
- data/gemfiles/newest.gemfile +3 -3
- data/gemfiles/oldest.gemfile +6 -6
- data/jiralicious.gemspec +37 -37
- data/lib/jiralicious.rb +2 -0
- data/lib/jiralicious/base.rb +226 -226
- data/lib/jiralicious/component.rb +103 -0
- data/lib/jiralicious/custom_field_option.rb +45 -45
- data/lib/jiralicious/errors.rb +27 -27
- data/lib/jiralicious/field.rb +58 -58
- data/lib/jiralicious/issue/fields.rb +197 -197
- data/lib/jiralicious/issue/watchers.rb +92 -92
- data/lib/jiralicious/project.rb +116 -64
- data/lib/jiralicious/session.rb +61 -61
- data/lib/jiralicious/version.rb +4 -4
- data/lib/jiralicious/versions.rb +150 -0
- data/spec/components_spec.rb +74 -0
- data/spec/configuration_spec.rb +41 -41
- data/spec/field_parser_spec.rb +73 -73
- data/spec/fixtures/avatar.json +6 -6
- data/spec/fixtures/avatar_custom.json +15 -15
- data/spec/fixtures/avatar_list.json +15 -15
- data/spec/fixtures/avatar_temp.json +6 -6
- data/spec/fixtures/comment_single.json +28 -28
- data/spec/fixtures/component.json +39 -0
- data/spec/fixtures/component_ric.json +4 -0
- data/spec/fixtures/component_updated.json +39 -0
- data/spec/fixtures/jira.yml +7 -7
- data/spec/fixtures/project_componets.json +80 -0
- data/spec/fixtures/project_versions.json +22 -0
- data/spec/fixtures/test.json +23 -23
- data/spec/fixtures/version.json +11 -0
- data/spec/fixtures/version_ric.json +5 -0
- data/spec/fixtures/version_uic.json +4 -0
- data/spec/fixtures/version_updated.json +11 -0
- data/spec/issue_spec.rb +385 -385
- data/spec/jiralicious_spec.rb +16 -16
- data/spec/project_spec.rb +25 -2
- data/spec/search_result_spec.rb +54 -54
- data/spec/support/configuration.rb +11 -11
- data/spec/support/http.rb +147 -111
- data/spec/versions_spec.rb +84 -0
- metadata +189 -170
- checksums.yaml +0 -7
data/spec/fixtures/avatar.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
{
|
2
|
-
"id": "10100",
|
3
|
-
"owner": "fred",
|
4
|
-
"isSystemAvatar": true,
|
5
|
-
"isSelected": true,
|
6
|
-
"selected": true
|
1
|
+
{
|
2
|
+
"id": "10100",
|
3
|
+
"owner": "fred",
|
4
|
+
"isSystemAvatar": true,
|
5
|
+
"isSelected": true,
|
6
|
+
"selected": true
|
7
7
|
}
|
@@ -1,16 +1,16 @@
|
|
1
|
-
{
|
2
|
-
"system": [
|
3
|
-
{
|
4
|
-
"id": "10100",
|
5
|
-
"isSystemAvatar": false,
|
6
|
-
"isSelected": false,
|
7
|
-
"selected": false
|
8
|
-
},
|
9
|
-
{
|
10
|
-
"id": "10101",
|
11
|
-
"isSystemAvatar": true,
|
12
|
-
"isSelected": false,
|
13
|
-
"selected": false
|
14
|
-
}
|
15
|
-
]
|
1
|
+
{
|
2
|
+
"system": [
|
3
|
+
{
|
4
|
+
"id": "10100",
|
5
|
+
"isSystemAvatar": false,
|
6
|
+
"isSelected": false,
|
7
|
+
"selected": false
|
8
|
+
},
|
9
|
+
{
|
10
|
+
"id": "10101",
|
11
|
+
"isSystemAvatar": true,
|
12
|
+
"isSelected": false,
|
13
|
+
"selected": false
|
14
|
+
}
|
15
|
+
]
|
16
16
|
}
|
@@ -1,16 +1,16 @@
|
|
1
|
-
{
|
2
|
-
"system": [
|
3
|
-
{
|
4
|
-
"id": "10100",
|
5
|
-
"isSystemAvatar": false,
|
6
|
-
"isSelected": false,
|
7
|
-
"selected": false
|
8
|
-
},
|
9
|
-
{
|
10
|
-
"id": "10101",
|
11
|
-
"isSystemAvatar": true,
|
12
|
-
"isSelected": false,
|
13
|
-
"selected": false
|
14
|
-
}
|
15
|
-
]
|
1
|
+
{
|
2
|
+
"system": [
|
3
|
+
{
|
4
|
+
"id": "10100",
|
5
|
+
"isSystemAvatar": false,
|
6
|
+
"isSelected": false,
|
7
|
+
"selected": false
|
8
|
+
},
|
9
|
+
{
|
10
|
+
"id": "10101",
|
11
|
+
"isSystemAvatar": true,
|
12
|
+
"isSelected": false,
|
13
|
+
"selected": false
|
14
|
+
}
|
15
|
+
]
|
16
16
|
}
|
@@ -1,7 +1,7 @@
|
|
1
|
-
{
|
2
|
-
"cropperWidth": 120,
|
3
|
-
"cropperOffsetX": 50,
|
4
|
-
"cropperOffsetY": 50,
|
5
|
-
"url": "http://example.com/jira/secure/temporaryavatar?cropped=true",
|
6
|
-
"needsCropping": true
|
1
|
+
{
|
2
|
+
"cropperWidth": 120,
|
3
|
+
"cropperOffsetX": 50,
|
4
|
+
"cropperOffsetY": 50,
|
5
|
+
"url": "http://example.com/jira/secure/temporaryavatar?cropped=true",
|
6
|
+
"needsCropping": true
|
7
7
|
}
|
@@ -1,29 +1,29 @@
|
|
1
|
-
{
|
2
|
-
"self": "http://www.example.com/rest/api/2/issue/10265/comment/10402",
|
3
|
-
"id": "10000",
|
4
|
-
"author": {
|
5
|
-
"self": "http://www.example.com/rest/api/2/user?username=fred",
|
6
|
-
"name": "fred",
|
7
|
-
"emailAddress": "fred@example.com",
|
8
|
-
"avatarUrls": {
|
9
|
-
"16x16": "http://www.example.com/secure/useravatar?size=small&avatarId=10122",
|
10
|
-
"48x48": "http://www.example.com/secure/useravatar?avatarId=10122"
|
11
|
-
},
|
12
|
-
"displayName": "JIRA Administrator",
|
13
|
-
"active": true
|
14
|
-
},
|
15
|
-
"body": "a new comment without key after specials",
|
16
|
-
"updateAuthor": {
|
17
|
-
"self": "http://www.example.com/rest/api/2/user?username=fred",
|
18
|
-
"name": "fred",
|
19
|
-
"emailAddress": "fred@example.com",
|
20
|
-
"avatarUrls": {
|
21
|
-
"16x16": "http://www.example.com/secure/useravatar?size=small&avatarId=10122",
|
22
|
-
"48x48": "http://www.example.com/secure/useravatar?avatarId=10122"
|
23
|
-
},
|
24
|
-
"displayName": "JIRA Administrator",
|
25
|
-
"active": true
|
26
|
-
},
|
27
|
-
"created": "2013-04-10T08:38:17.000-0500",
|
28
|
-
"updated": "2013-04-10T08:38:17.000-0500"
|
1
|
+
{
|
2
|
+
"self": "http://www.example.com/rest/api/2/issue/10265/comment/10402",
|
3
|
+
"id": "10000",
|
4
|
+
"author": {
|
5
|
+
"self": "http://www.example.com/rest/api/2/user?username=fred",
|
6
|
+
"name": "fred",
|
7
|
+
"emailAddress": "fred@example.com",
|
8
|
+
"avatarUrls": {
|
9
|
+
"16x16": "http://www.example.com/secure/useravatar?size=small&avatarId=10122",
|
10
|
+
"48x48": "http://www.example.com/secure/useravatar?avatarId=10122"
|
11
|
+
},
|
12
|
+
"displayName": "JIRA Administrator",
|
13
|
+
"active": true
|
14
|
+
},
|
15
|
+
"body": "a new comment without key after specials",
|
16
|
+
"updateAuthor": {
|
17
|
+
"self": "http://www.example.com/rest/api/2/user?username=fred",
|
18
|
+
"name": "fred",
|
19
|
+
"emailAddress": "fred@example.com",
|
20
|
+
"avatarUrls": {
|
21
|
+
"16x16": "http://www.example.com/secure/useravatar?size=small&avatarId=10122",
|
22
|
+
"48x48": "http://www.example.com/secure/useravatar?avatarId=10122"
|
23
|
+
},
|
24
|
+
"displayName": "JIRA Administrator",
|
25
|
+
"active": true
|
26
|
+
},
|
27
|
+
"created": "2013-04-10T08:38:17.000-0500",
|
28
|
+
"updated": "2013-04-10T08:38:17.000-0500"
|
29
29
|
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
2
|
+
"self": "http://www.example.com/jira/rest/api/2/component/10000",
|
3
|
+
"id": "10000",
|
4
|
+
"name": "Component 1",
|
5
|
+
"description": "This is a JIRA component",
|
6
|
+
"lead": {
|
7
|
+
"self": "http://www.example.com/jira/rest/api/2/user?username=fred",
|
8
|
+
"name": "fred",
|
9
|
+
"avatarUrls": {
|
10
|
+
"16x16": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
|
11
|
+
"48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
|
12
|
+
},
|
13
|
+
"displayName": "Fred F. User",
|
14
|
+
"active": false
|
15
|
+
},
|
16
|
+
"assigneeType": "PROJECT_LEAD",
|
17
|
+
"assignee": {
|
18
|
+
"self": "http://www.example.com/jira/rest/api/2/user?username=fred",
|
19
|
+
"name": "fred",
|
20
|
+
"avatarUrls": {
|
21
|
+
"16x16": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
|
22
|
+
"48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
|
23
|
+
},
|
24
|
+
"displayName": "Fred F. User",
|
25
|
+
"active": false
|
26
|
+
},
|
27
|
+
"realAssigneeType": "PROJECT_LEAD",
|
28
|
+
"realAssignee": {
|
29
|
+
"self": "http://www.example.com/jira/rest/api/2/user?username=fred",
|
30
|
+
"name": "fred",
|
31
|
+
"avatarUrls": {
|
32
|
+
"16x16": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
|
33
|
+
"48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
|
34
|
+
},
|
35
|
+
"displayName": "Fred F. User",
|
36
|
+
"active": false
|
37
|
+
},
|
38
|
+
"isAssigneeTypeValid": false
|
39
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
2
|
+
"self": "http://www.example.com/jira/rest/api/2/component/10000",
|
3
|
+
"id": "10000",
|
4
|
+
"name": "Component 2",
|
5
|
+
"description": "This is a JIRA component. Updated Component.",
|
6
|
+
"lead": {
|
7
|
+
"self": "http://www.example.com/jira/rest/api/2/user?username=fred",
|
8
|
+
"name": "fred",
|
9
|
+
"avatarUrls": {
|
10
|
+
"16x16": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
|
11
|
+
"48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
|
12
|
+
},
|
13
|
+
"displayName": "Fred F. User",
|
14
|
+
"active": false
|
15
|
+
},
|
16
|
+
"assigneeType": "PROJECT_LEAD",
|
17
|
+
"assignee": {
|
18
|
+
"self": "http://www.example.com/jira/rest/api/2/user?username=fred",
|
19
|
+
"name": "fred",
|
20
|
+
"avatarUrls": {
|
21
|
+
"16x16": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
|
22
|
+
"48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
|
23
|
+
},
|
24
|
+
"displayName": "Fred F. User",
|
25
|
+
"active": false
|
26
|
+
},
|
27
|
+
"realAssigneeType": "PROJECT_LEAD",
|
28
|
+
"realAssignee": {
|
29
|
+
"self": "http://www.example.com/jira/rest/api/2/user?username=fred",
|
30
|
+
"name": "fred",
|
31
|
+
"avatarUrls": {
|
32
|
+
"16x16": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
|
33
|
+
"48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
|
34
|
+
},
|
35
|
+
"displayName": "Fred F. User",
|
36
|
+
"active": false
|
37
|
+
},
|
38
|
+
"isAssigneeTypeValid": false
|
39
|
+
}
|
data/spec/fixtures/jira.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
# Jira Information
|
2
|
-
jira:
|
3
|
-
uri: http://localhost:8080
|
4
|
-
username: jira_admin
|
5
|
-
password: jira_admin
|
6
|
-
api_version: latest
|
7
|
-
auth_type: :basic
|
1
|
+
# Jira Information
|
2
|
+
jira:
|
3
|
+
uri: http://localhost:8080
|
4
|
+
username: jira_admin
|
5
|
+
password: jira_admin
|
6
|
+
api_version: latest
|
7
|
+
auth_type: :basic
|
@@ -0,0 +1,80 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"self": "http://www.example.com/jira/rest/api/2/component/10000",
|
4
|
+
"id": "10000",
|
5
|
+
"name": "Component 1",
|
6
|
+
"description": "This is a JIRA component",
|
7
|
+
"lead": {
|
8
|
+
"self": "http://www.example.com/jira/rest/api/2/user?username=fred",
|
9
|
+
"name": "fred",
|
10
|
+
"avatarUrls": {
|
11
|
+
"16x16": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
|
12
|
+
"48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
|
13
|
+
},
|
14
|
+
"displayName": "Fred F. User",
|
15
|
+
"active": false
|
16
|
+
},
|
17
|
+
"assigneeType": "PROJECT_LEAD",
|
18
|
+
"assignee": {
|
19
|
+
"self": "http://www.example.com/jira/rest/api/2/user?username=fred",
|
20
|
+
"name": "fred",
|
21
|
+
"avatarUrls": {
|
22
|
+
"16x16": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
|
23
|
+
"48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
|
24
|
+
},
|
25
|
+
"displayName": "Fred F. User",
|
26
|
+
"active": false
|
27
|
+
},
|
28
|
+
"realAssigneeType": "PROJECT_LEAD",
|
29
|
+
"realAssignee": {
|
30
|
+
"self": "http://www.example.com/jira/rest/api/2/user?username=fred",
|
31
|
+
"name": "fred",
|
32
|
+
"avatarUrls": {
|
33
|
+
"16x16": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
|
34
|
+
"48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
|
35
|
+
},
|
36
|
+
"displayName": "Fred F. User",
|
37
|
+
"active": false
|
38
|
+
},
|
39
|
+
"isAssigneeTypeValid": false
|
40
|
+
},
|
41
|
+
{
|
42
|
+
"self": "http://www.example.com/jira/rest/api/2/component/10000",
|
43
|
+
"id": "10050",
|
44
|
+
"name": "PXA",
|
45
|
+
"description": "This is a another JIRA component",
|
46
|
+
"lead": {
|
47
|
+
"self": "http://www.example.com/jira/rest/api/2/user?username=fred",
|
48
|
+
"name": "fred",
|
49
|
+
"avatarUrls": {
|
50
|
+
"16x16": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
|
51
|
+
"48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
|
52
|
+
},
|
53
|
+
"displayName": "Fred F. User",
|
54
|
+
"active": false
|
55
|
+
},
|
56
|
+
"assigneeType": "PROJECT_LEAD",
|
57
|
+
"assignee": {
|
58
|
+
"self": "http://www.example.com/jira/rest/api/2/user?username=fred",
|
59
|
+
"name": "fred",
|
60
|
+
"avatarUrls": {
|
61
|
+
"16x16": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
|
62
|
+
"48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
|
63
|
+
},
|
64
|
+
"displayName": "Fred F. User",
|
65
|
+
"active": false
|
66
|
+
},
|
67
|
+
"realAssigneeType": "PROJECT_LEAD",
|
68
|
+
"realAssignee": {
|
69
|
+
"self": "http://www.example.com/jira/rest/api/2/user?username=fred",
|
70
|
+
"name": "fred",
|
71
|
+
"avatarUrls": {
|
72
|
+
"16x16": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
|
73
|
+
"48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
|
74
|
+
},
|
75
|
+
"displayName": "Fred F. User",
|
76
|
+
"active": false
|
77
|
+
},
|
78
|
+
"isAssigneeTypeValid": false
|
79
|
+
}
|
80
|
+
]
|
@@ -0,0 +1,22 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"self": "http://www.example.com/jira/rest/api/2/version/10000",
|
4
|
+
"id": "10000",
|
5
|
+
"description": "An excellent version",
|
6
|
+
"name": "New Version 1",
|
7
|
+
"archived": false,
|
8
|
+
"released": true,
|
9
|
+
"releaseDate": "2010-07-05",
|
10
|
+
"overdue": true,
|
11
|
+
"userReleaseDate": "5/Jul/2010"
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"self": "http://www.example.com/jira/rest/api/2/version/10010",
|
15
|
+
"id": "10010",
|
16
|
+
"description": "Minor Bugfix version",
|
17
|
+
"name": "Next Version",
|
18
|
+
"archived": false,
|
19
|
+
"released": false,
|
20
|
+
"overdue": false
|
21
|
+
}
|
22
|
+
]
|
data/spec/fixtures/test.json
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
<Jiralicious::Issue::Comment
|
2
|
-
author={
|
3
|
-
"avatarUrls"=>{
|
4
|
-
"16x16"=>"http://rome:8080/secure/useravatar?size=small&avatarId=10122",
|
5
|
-
"48x48"=>"http://rome:8080/secure/useravatar?avatarId=10122"},
|
6
|
-
"name"=>"jira_admin",
|
7
|
-
"emailAddress"=>"richard.waskiewicz@hcaudit.com",
|
8
|
-
"active"=>true,
|
9
|
-
"displayName"=>"JIRA Administrator",
|
10
|
-
"self"=>"http://rome:8080/rest/api/2/user?username=jira_admin"}
|
11
|
-
body="a new comment without key after specials"
|
12
|
-
created="2013-04-10T08:38:17.000-0500"
|
13
|
-
id="10402"
|
14
|
-
self="http://rome:8080/rest/api/2/issue/10265/comment/10402"
|
15
|
-
updateAuthor={
|
16
|
-
"avatarUrls"=>{
|
17
|
-
"16x16"=>"http://rome:8080/secure/useravatar?size=small&avatarId=10122",
|
18
|
-
"48x48"=>"http://rome:8080/secure/useravatar?avatarId=10122"},
|
19
|
-
"name"=>"jira_admin",
|
20
|
-
"emailAddress"=>"richard.waskiewicz@hcaudit.com",
|
21
|
-
"active"=>true,
|
22
|
-
"displayName"=>"JIRA Administrator",
|
23
|
-
"self"=>"http://rome:8080/rest/api/2/user?username=jira_admin"}
|
1
|
+
<Jiralicious::Issue::Comment
|
2
|
+
author={
|
3
|
+
"avatarUrls"=>{
|
4
|
+
"16x16"=>"http://rome:8080/secure/useravatar?size=small&avatarId=10122",
|
5
|
+
"48x48"=>"http://rome:8080/secure/useravatar?avatarId=10122"},
|
6
|
+
"name"=>"jira_admin",
|
7
|
+
"emailAddress"=>"richard.waskiewicz@hcaudit.com",
|
8
|
+
"active"=>true,
|
9
|
+
"displayName"=>"JIRA Administrator",
|
10
|
+
"self"=>"http://rome:8080/rest/api/2/user?username=jira_admin"}
|
11
|
+
body="a new comment without key after specials"
|
12
|
+
created="2013-04-10T08:38:17.000-0500"
|
13
|
+
id="10402"
|
14
|
+
self="http://rome:8080/rest/api/2/issue/10265/comment/10402"
|
15
|
+
updateAuthor={
|
16
|
+
"avatarUrls"=>{
|
17
|
+
"16x16"=>"http://rome:8080/secure/useravatar?size=small&avatarId=10122",
|
18
|
+
"48x48"=>"http://rome:8080/secure/useravatar?avatarId=10122"},
|
19
|
+
"name"=>"jira_admin",
|
20
|
+
"emailAddress"=>"richard.waskiewicz@hcaudit.com",
|
21
|
+
"active"=>true,
|
22
|
+
"displayName"=>"JIRA Administrator",
|
23
|
+
"self"=>"http://rome:8080/rest/api/2/user?username=jira_admin"}
|
24
24
|
updated="2013-04-10T08:38:17.000-0500">
|
@@ -0,0 +1,11 @@
|
|
1
|
+
{
|
2
|
+
"self": "http://www.example.com/jira/rest/api/2/version/10000",
|
3
|
+
"id": "10000",
|
4
|
+
"description": "An excellent version",
|
5
|
+
"name": "Version 1",
|
6
|
+
"archived": false,
|
7
|
+
"released": true,
|
8
|
+
"releaseDate": "2010-07-05",
|
9
|
+
"overdue": true,
|
10
|
+
"userReleaseDate": "5/Jul/2010"
|
11
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
{
|
2
|
+
"self": "http://www.example.com/jira/rest/api/2/version/10000",
|
3
|
+
"id": "10000",
|
4
|
+
"description": "This is a JIRA version. Updated Version.",
|
5
|
+
"name": "Version 2",
|
6
|
+
"archived": false,
|
7
|
+
"released": true,
|
8
|
+
"releaseDate": "2010-07-05",
|
9
|
+
"overdue": true,
|
10
|
+
"userReleaseDate": "5/Jul/2010"
|
11
|
+
}
|
data/spec/issue_spec.rb
CHANGED
@@ -1,385 +1,385 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require "spec_helper"
|
3
|
-
|
4
|
-
describe Jiralicious::Issue, "finding" do
|
5
|
-
|
6
|
-
before :each do
|
7
|
-
Jiralicious.configure do |config|
|
8
|
-
config.username = "jstewart"
|
9
|
-
config.password = "topsecret"
|
10
|
-
config.uri = "http://jstewart:topsecret@localhost"
|
11
|
-
config.auth_type = :basic
|
12
|
-
config.api_version = "latest"
|
13
|
-
end
|
14
|
-
|
15
|
-
FakeWeb.register_uri(:get,
|
16
|
-
"#{Jiralicious.rest_path}/issue/EX-1",
|
17
|
-
:status => "200",
|
18
|
-
:body => issue_json)
|
19
|
-
FakeWeb.register_uri(:get,
|
20
|
-
"#{Jiralicious.rest_path}/issue/EX-1/comment/",
|
21
|
-
:status => "200",
|
22
|
-
:body => comment_json)
|
23
|
-
FakeWeb.register_uri(:get,
|
24
|
-
"#{Jiralicious.rest_path}/issue/EX-1/watchers/",
|
25
|
-
:status => "200",
|
26
|
-
:body => watchers_json)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "finds the issue by key" do
|
30
|
-
Jiralicious::Issue.find("EX-1").should be_instance_of(Jiralicious::Issue)
|
31
|
-
issue = Jiralicious::Issue.find("EX-1")
|
32
|
-
end
|
33
|
-
|
34
|
-
it "raises an exception when the issue can't be found or can't be viewed" do
|
35
|
-
lambda {
|
36
|
-
FakeWeb.register_uri(:get,
|
37
|
-
"#{Jiralicious.rest_path}/issue/EX-1",
|
38
|
-
:body => '{"errorMessages": ["error"]}',
|
39
|
-
:status => ["404" "Not Found"])
|
40
|
-
Jiralicious::Issue.find("EX-1")
|
41
|
-
}.should raise_error(Jiralicious::IssueNotFound)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "translates the JSON properly" do
|
45
|
-
issue = Jiralicious::Issue.find("EX-1")
|
46
|
-
issue.jira_key.should == "EX-1"
|
47
|
-
issue.jira_self.should == "http://example.com:8080/jira/rest/api/2.0/issue/EX-1"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
#################################################################################################################
|
52
|
-
|
53
|
-
describe Jiralicious::Issue, "Managing Issues" do
|
54
|
-
|
55
|
-
before :each do
|
56
|
-
Jiralicious.configure do |config|
|
57
|
-
config.username = "jstewart"
|
58
|
-
config.password = "topsecret"
|
59
|
-
config.uri = "http://jstewart:topsecret@localhost"
|
60
|
-
config.auth_type = :basic
|
61
|
-
config.api_version = "latest"
|
62
|
-
end
|
63
|
-
|
64
|
-
FakeWeb.register_uri(:post,
|
65
|
-
"#{Jiralicious.rest_path}/issue/",
|
66
|
-
:status => "200",
|
67
|
-
:body => issue_create_json)
|
68
|
-
FakeWeb.register_uri(:get,
|
69
|
-
"#{Jiralicious.rest_path}/issue/EX-1",
|
70
|
-
:status => "200",
|
71
|
-
:body => issue_json)
|
72
|
-
FakeWeb.register_uri(:get,
|
73
|
-
"#{Jiralicious.rest_path}/issue/EX-1/comment/",
|
74
|
-
:status => "200",
|
75
|
-
:body => comment_json)
|
76
|
-
FakeWeb.register_uri(:get,
|
77
|
-
"#{Jiralicious.rest_path}/issue/EX-1/watchers/",
|
78
|
-
:status => "200",
|
79
|
-
:body => watchers_json)
|
80
|
-
FakeWeb.register_uri(:get,
|
81
|
-
"#{Jiralicious.rest_path}/issue/EX-2",
|
82
|
-
:status => "200",
|
83
|
-
:body => issue_2_json)
|
84
|
-
FakeWeb.register_uri(:get,
|
85
|
-
"#{Jiralicious.rest_path}/issue/EX-2/comment/",
|
86
|
-
:status => "200",
|
87
|
-
:body => '{"startAt": 0,"maxResults": 0,"total": 0,"comments": []}')
|
88
|
-
FakeWeb.register_uri(:get,
|
89
|
-
"#{Jiralicious.rest_path}/issue/EX-2/watchers/",
|
90
|
-
:status => "200",
|
91
|
-
:body => '{"self": "http://www.example.com/jira/rest/api/2/issue/EX-1/watchers","isWatching": false,"watchCount": 1,"watchers": [{"self": "http://www.example.com/jira/rest/api/2/user?username=fred","name": "fred","avatarUrls": {"16x16": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred","48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"},"displayName": "Fred F. User","active": false}]}')
|
92
|
-
FakeWeb.register_uri(:get,
|
93
|
-
"#{Jiralicious.rest_path}/issue/EX-3",
|
94
|
-
:status => "200",
|
95
|
-
:body => issue_3_json)
|
96
|
-
FakeWeb.register_uri(:put,
|
97
|
-
"#{Jiralicious.rest_path}/issue/EX-3",
|
98
|
-
:status => "200",
|
99
|
-
:body => issue_update_json)
|
100
|
-
FakeWeb.register_uri(:get,
|
101
|
-
"#{Jiralicious.rest_path}/issue/EX-3/comment/",
|
102
|
-
:status => "200",
|
103
|
-
:body => '{"startAt": 0,"maxResults": 0,"total": 0,"comments": []}')
|
104
|
-
FakeWeb.register_uri(:get,
|
105
|
-
"#{Jiralicious.rest_path}/issue/EX-3/watchers/",
|
106
|
-
:status => "200",
|
107
|
-
:body => '{"self": "http://www.example.com/jira/rest/api/2/issue/EX-1/watchers","isWatching": false,"watchCount": 1,"watchers": [{"self": "http://www.example.com/jira/rest/api/2/user?username=fred","name": "fred","avatarUrls": {"16x16": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred","48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"},"displayName": "Fred F. User","active": false}]}')
|
108
|
-
end
|
109
|
-
|
110
|
-
it "loads a hash in to the issue without subfields" do
|
111
|
-
issue = Jiralicious::Issue.new
|
112
|
-
issue.load(JSON.parse(issue_json), false)
|
113
|
-
issue.jira_key.should == 'EX-1'
|
114
|
-
issue.comments.count.should == 0
|
115
|
-
issue.watchers.count.should == 0
|
116
|
-
end
|
117
|
-
|
118
|
-
it "loads a hash in to the issue with subfields" do
|
119
|
-
issue = Jiralicious::Issue.new
|
120
|
-
issue.load(JSON.parse(issue_json))
|
121
|
-
issue.jira_key.should == 'EX-1'
|
122
|
-
issue.comments.comments.count.should == 1
|
123
|
-
issue.watchers.watchers.count.should == 1
|
124
|
-
end
|
125
|
-
|
126
|
-
it "creates a new issue through fields" do
|
127
|
-
issue = Jiralicious::Issue.new
|
128
|
-
issue.fields.set_id("project", "10000")
|
129
|
-
issue.fields.set("summary", "this is a test of creating a scratch ticket")
|
130
|
-
issue.fields.set_id("issuetype", "7")
|
131
|
-
issue.fields.set_name("assignee", "stanley.handschuh")
|
132
|
-
issue.fields.set_id("priority", "1")
|
133
|
-
issue.fields.set("labels", ["new_label_p"])
|
134
|
-
issue.fields.set("environment", "example of environment")
|
135
|
-
issue.fields.set("description", "example of the description extending")
|
136
|
-
issue.save!
|
137
|
-
issue.jira_key.should == 'EX-2'
|
138
|
-
issue.comments.comments.count.should == 0
|
139
|
-
issue.watchers.watchers.count.should == 1
|
140
|
-
end
|
141
|
-
|
142
|
-
it "creates a new issue thgrough load with reload" do
|
143
|
-
hash = {"fields" => {"project" => {"id" => "10000"},
|
144
|
-
"summary" => "this is a test of creating a scratch ticket",
|
145
|
-
"issuetype" => {"id" => "7"},
|
146
|
-
"assignee" => {"name" => "stanley.handschuh"},
|
147
|
-
"priority" => {"id" => "1"},
|
148
|
-
"labels" => ["new_label_p"],
|
149
|
-
"environment" => "example of environment",
|
150
|
-
"description" => "example of the description extending"
|
151
|
-
}}
|
152
|
-
issue = Jiralicious::Issue.new
|
153
|
-
issue.load(hash, true)
|
154
|
-
issue.save!
|
155
|
-
issue.jira_key.should == 'EX-2'
|
156
|
-
issue.comments.comments.count.should == 0
|
157
|
-
issue.watchers.watchers.count.should == 1
|
158
|
-
end
|
159
|
-
|
160
|
-
it "creates a new issue thgrough load without reload" do
|
161
|
-
hash = {"fields" => {"project" => {"id" => "10000"},
|
162
|
-
"summary" => "this is a test of creating a scratch ticket",
|
163
|
-
"issuetype" => {"id" => "7"},
|
164
|
-
"assignee" => {"name" => "stanley.handschuh"},
|
165
|
-
"priority" => {"id" => "1"},
|
166
|
-
"labels" => ["new_label_p"],
|
167
|
-
"environment" => "example of environment",
|
168
|
-
"description" => "example of the description extending"
|
169
|
-
}}
|
170
|
-
issue = Jiralicious::Issue.new
|
171
|
-
issue.load(hash)
|
172
|
-
issue.save!
|
173
|
-
issue.jira_key.should == 'EX-2'
|
174
|
-
issue.comments.comments.count.should == 0
|
175
|
-
issue.watchers.watchers.count.should == 1
|
176
|
-
end
|
177
|
-
|
178
|
-
it "creates a new issue through new" do
|
179
|
-
hash = {"project" => {"id" => "10000"},
|
180
|
-
"summary" => "this is a test of creating a scratch ticket",
|
181
|
-
"issuetype" => {"id" => "7"},
|
182
|
-
"assignee" => {"name" => "stanley.handschuh"},
|
183
|
-
"priority" => {"id" => "1"},
|
184
|
-
"labels" => ["new_label_p"],
|
185
|
-
"environment" => "example of environment",
|
186
|
-
"description" => "example of the description extending"
|
187
|
-
}
|
188
|
-
issue = Jiralicious::Issue.new(hash)
|
189
|
-
issue.save!
|
190
|
-
issue.jira_key.should == 'EX-2'
|
191
|
-
issue.comments.comments.count.should == 0
|
192
|
-
issue.watchers.watchers.count.should == 1
|
193
|
-
end
|
194
|
-
|
195
|
-
it "updates a new issue" do
|
196
|
-
issue = Jiralicious::Issue.find("EX-3")
|
197
|
-
issue.fields.append_a("labels", ["test_label"])
|
198
|
-
issue.fields.append_s("description", " updated description ")
|
199
|
-
issue.save
|
200
|
-
issue.jira_key.should == 'EX-3'
|
201
|
-
issue['fields']['labels'].should == ["test_label"]
|
202
|
-
issue['fields']['description'].should == "example bug report updated description "
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
#################################################################################################################
|
207
|
-
|
208
|
-
describe Jiralicious::Issue, "Managing Issues" do
|
209
|
-
|
210
|
-
before :each do
|
211
|
-
Jiralicious.configure do |config|
|
212
|
-
config.username = "jstewart"
|
213
|
-
config.password = "topsecret"
|
214
|
-
config.uri = "http://jstewart:topsecret@localhost"
|
215
|
-
config.auth_type = :basic
|
216
|
-
config.api_version = "latest"
|
217
|
-
end
|
218
|
-
|
219
|
-
FakeWeb.register_uri(:get,
|
220
|
-
"#{Jiralicious.rest_path}/issue/EX-1",
|
221
|
-
:status => "200",
|
222
|
-
:body => issue_json)
|
223
|
-
FakeWeb.register_uri(:delete,
|
224
|
-
"#{Jiralicious.rest_path}/issue/EX-1",
|
225
|
-
:status => "204")
|
226
|
-
FakeWeb.register_uri(:put,
|
227
|
-
"#{Jiralicious.rest_path}/issue/EX-1/assignee",
|
228
|
-
:status => "204")
|
229
|
-
FakeWeb.register_uri(:get,
|
230
|
-
"#{Jiralicious.rest_path}/issue/EX-1/comment/",
|
231
|
-
:status => "200",
|
232
|
-
:body => comment_json)
|
233
|
-
FakeWeb.register_uri(:get,
|
234
|
-
"#{Jiralicious.rest_path}/issue/EX-1/watchers/",
|
235
|
-
:status => "200",
|
236
|
-
:body => watchers_json)
|
237
|
-
end
|
238
|
-
|
239
|
-
it "update the assignee instance" do
|
240
|
-
issue = Jiralicious::Issue.find("EX-1")
|
241
|
-
response = issue.set_assignee("jira_admin")
|
242
|
-
response.response.class.should == Net::HTTPNoContent
|
243
|
-
end
|
244
|
-
|
245
|
-
it "update the assignee class" do
|
246
|
-
response = Jiralicious::Issue.assignee("jira_admin", "EX-1")
|
247
|
-
response.response.class.should == Net::HTTPNoContent
|
248
|
-
end
|
249
|
-
|
250
|
-
it "deletes the issue at the class level" do
|
251
|
-
response = Jiralicious::Issue.remove("EX-1")
|
252
|
-
response.response.class.should == Net::HTTPNoContent
|
253
|
-
end
|
254
|
-
|
255
|
-
it "deletes the issue at the instance level" do
|
256
|
-
issue = Jiralicious::Issue.find("EX-1")
|
257
|
-
response = issue.remove
|
258
|
-
response.response.class.should == Net::HTTPNoContent
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
#################################################################################################################
|
263
|
-
|
264
|
-
describe Jiralicious::Issue, "Issue Information and Field Class" do
|
265
|
-
|
266
|
-
before :each do
|
267
|
-
Jiralicious.configure do |config|
|
268
|
-
config.username = "jstewart"
|
269
|
-
config.password = "topsecret"
|
270
|
-
config.uri = "http://jstewart:topsecret@localhost"
|
271
|
-
config.auth_type = :basic
|
272
|
-
config.api_version = "latest"
|
273
|
-
end
|
274
|
-
|
275
|
-
FakeWeb.register_uri(:get,
|
276
|
-
"#{Jiralicious.rest_path}/issue/createmeta?projectKeys=EX&expand=projects.issuetypes.fields.&issuetypeIds=",
|
277
|
-
:status => "200",
|
278
|
-
:body => issue_createmeta_json)
|
279
|
-
FakeWeb.register_uri(:get,
|
280
|
-
"#{Jiralicious.rest_path}/issue/EX-1/editmeta",
|
281
|
-
:status => "200",
|
282
|
-
:body => issue_editmeta_json)
|
283
|
-
FakeWeb.register_uri(:get,
|
284
|
-
"#{Jiralicious.rest_path}/issue/EX-1",
|
285
|
-
:status => "200",
|
286
|
-
:body => issue_json)
|
287
|
-
FakeWeb.register_uri(:get,
|
288
|
-
"#{Jiralicious.rest_path}/issue/EX-1/comment/",
|
289
|
-
:status => "200",
|
290
|
-
:body => comment_json)
|
291
|
-
FakeWeb.register_uri(:get,
|
292
|
-
"#{Jiralicious.rest_path}/issue/EX-1/watchers/",
|
293
|
-
:status => "200",
|
294
|
-
:body => watchers_json)
|
295
|
-
end
|
296
|
-
|
297
|
-
it "retrieve createmeta for project class level" do
|
298
|
-
meta = Jiralicious::Issue.createmeta("EX")
|
299
|
-
meta.class.should == Jiralicious::Field
|
300
|
-
meta.projects[0].key.should == "EX"
|
301
|
-
end
|
302
|
-
|
303
|
-
it "retrieve createmeta for project instance level" do
|
304
|
-
issue = Jiralicious::Issue.find("EX-1")
|
305
|
-
meta = issue.createmeta
|
306
|
-
meta.class.should == Jiralicious::Field
|
307
|
-
meta.projects[0].key.should == "EX"
|
308
|
-
end
|
309
|
-
|
310
|
-
it "retrieve editmeta for project class level" do
|
311
|
-
meta = Jiralicious::Issue.editmeta("EX-1")
|
312
|
-
meta.class.should == Jiralicious::Field
|
313
|
-
meta.key.should == "EX-1"
|
314
|
-
meta.fields.summary.required.should == false
|
315
|
-
end
|
316
|
-
|
317
|
-
it "retrieve editmeta for project instance level" do
|
318
|
-
issue = Jiralicious::Issue.find("EX-1")
|
319
|
-
meta = issue.editmeta
|
320
|
-
meta.class.should == Jiralicious::Field
|
321
|
-
meta.key.should == "EX-1"
|
322
|
-
meta.jira_key.should == "EX-1"
|
323
|
-
meta.fields.summary.required.should == false
|
324
|
-
end
|
325
|
-
|
326
|
-
end
|
327
|
-
|
328
|
-
#################################################################################################################
|
329
|
-
|
330
|
-
describe Jiralicious::Issue, "transitions" do
|
331
|
-
|
332
|
-
before :each do
|
333
|
-
Jiralicious.configure do |config|
|
334
|
-
config.username = "jstewart"
|
335
|
-
config.password = "topsecret"
|
336
|
-
config.uri = "http://jstewart:topsecret@localhost"
|
337
|
-
config.auth_type = :basic
|
338
|
-
config.api_version = "latest"
|
339
|
-
end
|
340
|
-
|
341
|
-
end
|
342
|
-
|
343
|
-
it "returns list of possible transitions" do
|
344
|
-
FakeWeb.register_uri(:get,
|
345
|
-
"#{Jiralicious.rest_path}/issue/EX-1/transitions",
|
346
|
-
:status => "200",
|
347
|
-
:body => transitions_json)
|
348
|
-
|
349
|
-
transitions = Jiralicious::Issue.get_transitions("#{Jiralicious.rest_path}/issue/EX-1/transitions")
|
350
|
-
transitions.should be_instance_of(Hash)
|
351
|
-
end
|
352
|
-
|
353
|
-
it "performs transition" do
|
354
|
-
FakeWeb.register_uri(:post,
|
355
|
-
"#{Jiralicious.rest_path}/issue/EX-1/transitions",
|
356
|
-
:status => "204",
|
357
|
-
:body => nil)
|
358
|
-
|
359
|
-
result = Jiralicious::Issue.transition("#{Jiralicious.rest_path}/issue/EX-1/transitions",
|
360
|
-
{"transition" => "3", "fields" => []})
|
361
|
-
result.should be_nil
|
362
|
-
end
|
363
|
-
|
364
|
-
it "raises an exception on transition failure" do
|
365
|
-
FakeWeb.register_uri(:post,
|
366
|
-
"#{Jiralicious.rest_path}/issue/EX-1/transitions",
|
367
|
-
:status => "400",
|
368
|
-
:body => %q{{"errorMessages":["Workflow operation is not valid"],"errors":{}}})
|
369
|
-
lambda {
|
370
|
-
result = Jiralicious::Issue.transition("#{Jiralicious.rest_path}/issue/EX-1/transitions",
|
371
|
-
{"transition" => "invalid"})
|
372
|
-
}.should raise_error(Jiralicious::TransitionError)
|
373
|
-
end
|
374
|
-
|
375
|
-
it "raises an IssueNotFound exception if issue is not found" do
|
376
|
-
FakeWeb.register_uri(:post,
|
377
|
-
"#{Jiralicious.rest_path}/issue/EX-1/transitions",
|
378
|
-
:status => "404",
|
379
|
-
:body => %q{{"errorMessages":["Issue Does Not Exist"],"errors":{}}})
|
380
|
-
lambda {
|
381
|
-
result = Jiralicious::Issue.transition("#{Jiralicious.rest_path}/issue/EX-1/transitions",
|
382
|
-
{"transition" => "invalid"})
|
383
|
-
}.should raise_error(Jiralicious::IssueNotFound)
|
384
|
-
end
|
385
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe Jiralicious::Issue, "finding" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
Jiralicious.configure do |config|
|
8
|
+
config.username = "jstewart"
|
9
|
+
config.password = "topsecret"
|
10
|
+
config.uri = "http://jstewart:topsecret@localhost"
|
11
|
+
config.auth_type = :basic
|
12
|
+
config.api_version = "latest"
|
13
|
+
end
|
14
|
+
|
15
|
+
FakeWeb.register_uri(:get,
|
16
|
+
"#{Jiralicious.rest_path}/issue/EX-1",
|
17
|
+
:status => "200",
|
18
|
+
:body => issue_json)
|
19
|
+
FakeWeb.register_uri(:get,
|
20
|
+
"#{Jiralicious.rest_path}/issue/EX-1/comment/",
|
21
|
+
:status => "200",
|
22
|
+
:body => comment_json)
|
23
|
+
FakeWeb.register_uri(:get,
|
24
|
+
"#{Jiralicious.rest_path}/issue/EX-1/watchers/",
|
25
|
+
:status => "200",
|
26
|
+
:body => watchers_json)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "finds the issue by key" do
|
30
|
+
Jiralicious::Issue.find("EX-1").should be_instance_of(Jiralicious::Issue)
|
31
|
+
issue = Jiralicious::Issue.find("EX-1")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "raises an exception when the issue can't be found or can't be viewed" do
|
35
|
+
lambda {
|
36
|
+
FakeWeb.register_uri(:get,
|
37
|
+
"#{Jiralicious.rest_path}/issue/EX-1",
|
38
|
+
:body => '{"errorMessages": ["error"]}',
|
39
|
+
:status => ["404" "Not Found"])
|
40
|
+
Jiralicious::Issue.find("EX-1")
|
41
|
+
}.should raise_error(Jiralicious::IssueNotFound)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "translates the JSON properly" do
|
45
|
+
issue = Jiralicious::Issue.find("EX-1")
|
46
|
+
issue.jira_key.should == "EX-1"
|
47
|
+
issue.jira_self.should == "http://example.com:8080/jira/rest/api/2.0/issue/EX-1"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
#################################################################################################################
|
52
|
+
|
53
|
+
describe Jiralicious::Issue, "Managing Issues" do
|
54
|
+
|
55
|
+
before :each do
|
56
|
+
Jiralicious.configure do |config|
|
57
|
+
config.username = "jstewart"
|
58
|
+
config.password = "topsecret"
|
59
|
+
config.uri = "http://jstewart:topsecret@localhost"
|
60
|
+
config.auth_type = :basic
|
61
|
+
config.api_version = "latest"
|
62
|
+
end
|
63
|
+
|
64
|
+
FakeWeb.register_uri(:post,
|
65
|
+
"#{Jiralicious.rest_path}/issue/",
|
66
|
+
:status => "200",
|
67
|
+
:body => issue_create_json)
|
68
|
+
FakeWeb.register_uri(:get,
|
69
|
+
"#{Jiralicious.rest_path}/issue/EX-1",
|
70
|
+
:status => "200",
|
71
|
+
:body => issue_json)
|
72
|
+
FakeWeb.register_uri(:get,
|
73
|
+
"#{Jiralicious.rest_path}/issue/EX-1/comment/",
|
74
|
+
:status => "200",
|
75
|
+
:body => comment_json)
|
76
|
+
FakeWeb.register_uri(:get,
|
77
|
+
"#{Jiralicious.rest_path}/issue/EX-1/watchers/",
|
78
|
+
:status => "200",
|
79
|
+
:body => watchers_json)
|
80
|
+
FakeWeb.register_uri(:get,
|
81
|
+
"#{Jiralicious.rest_path}/issue/EX-2",
|
82
|
+
:status => "200",
|
83
|
+
:body => issue_2_json)
|
84
|
+
FakeWeb.register_uri(:get,
|
85
|
+
"#{Jiralicious.rest_path}/issue/EX-2/comment/",
|
86
|
+
:status => "200",
|
87
|
+
:body => '{"startAt": 0,"maxResults": 0,"total": 0,"comments": []}')
|
88
|
+
FakeWeb.register_uri(:get,
|
89
|
+
"#{Jiralicious.rest_path}/issue/EX-2/watchers/",
|
90
|
+
:status => "200",
|
91
|
+
:body => '{"self": "http://www.example.com/jira/rest/api/2/issue/EX-1/watchers","isWatching": false,"watchCount": 1,"watchers": [{"self": "http://www.example.com/jira/rest/api/2/user?username=fred","name": "fred","avatarUrls": {"16x16": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred","48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"},"displayName": "Fred F. User","active": false}]}')
|
92
|
+
FakeWeb.register_uri(:get,
|
93
|
+
"#{Jiralicious.rest_path}/issue/EX-3",
|
94
|
+
:status => "200",
|
95
|
+
:body => issue_3_json)
|
96
|
+
FakeWeb.register_uri(:put,
|
97
|
+
"#{Jiralicious.rest_path}/issue/EX-3",
|
98
|
+
:status => "200",
|
99
|
+
:body => issue_update_json)
|
100
|
+
FakeWeb.register_uri(:get,
|
101
|
+
"#{Jiralicious.rest_path}/issue/EX-3/comment/",
|
102
|
+
:status => "200",
|
103
|
+
:body => '{"startAt": 0,"maxResults": 0,"total": 0,"comments": []}')
|
104
|
+
FakeWeb.register_uri(:get,
|
105
|
+
"#{Jiralicious.rest_path}/issue/EX-3/watchers/",
|
106
|
+
:status => "200",
|
107
|
+
:body => '{"self": "http://www.example.com/jira/rest/api/2/issue/EX-1/watchers","isWatching": false,"watchCount": 1,"watchers": [{"self": "http://www.example.com/jira/rest/api/2/user?username=fred","name": "fred","avatarUrls": {"16x16": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred","48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"},"displayName": "Fred F. User","active": false}]}')
|
108
|
+
end
|
109
|
+
|
110
|
+
it "loads a hash in to the issue without subfields" do
|
111
|
+
issue = Jiralicious::Issue.new
|
112
|
+
issue.load(JSON.parse(issue_json), false)
|
113
|
+
issue.jira_key.should == 'EX-1'
|
114
|
+
issue.comments.count.should == 0
|
115
|
+
issue.watchers.count.should == 0
|
116
|
+
end
|
117
|
+
|
118
|
+
it "loads a hash in to the issue with subfields" do
|
119
|
+
issue = Jiralicious::Issue.new
|
120
|
+
issue.load(JSON.parse(issue_json))
|
121
|
+
issue.jira_key.should == 'EX-1'
|
122
|
+
issue.comments.comments.count.should == 1
|
123
|
+
issue.watchers.watchers.count.should == 1
|
124
|
+
end
|
125
|
+
|
126
|
+
it "creates a new issue through fields" do
|
127
|
+
issue = Jiralicious::Issue.new
|
128
|
+
issue.fields.set_id("project", "10000")
|
129
|
+
issue.fields.set("summary", "this is a test of creating a scratch ticket")
|
130
|
+
issue.fields.set_id("issuetype", "7")
|
131
|
+
issue.fields.set_name("assignee", "stanley.handschuh")
|
132
|
+
issue.fields.set_id("priority", "1")
|
133
|
+
issue.fields.set("labels", ["new_label_p"])
|
134
|
+
issue.fields.set("environment", "example of environment")
|
135
|
+
issue.fields.set("description", "example of the description extending")
|
136
|
+
issue.save!
|
137
|
+
issue.jira_key.should == 'EX-2'
|
138
|
+
issue.comments.comments.count.should == 0
|
139
|
+
issue.watchers.watchers.count.should == 1
|
140
|
+
end
|
141
|
+
|
142
|
+
it "creates a new issue thgrough load with reload" do
|
143
|
+
hash = {"fields" => {"project" => {"id" => "10000"},
|
144
|
+
"summary" => "this is a test of creating a scratch ticket",
|
145
|
+
"issuetype" => {"id" => "7"},
|
146
|
+
"assignee" => {"name" => "stanley.handschuh"},
|
147
|
+
"priority" => {"id" => "1"},
|
148
|
+
"labels" => ["new_label_p"],
|
149
|
+
"environment" => "example of environment",
|
150
|
+
"description" => "example of the description extending"
|
151
|
+
}}
|
152
|
+
issue = Jiralicious::Issue.new
|
153
|
+
issue.load(hash, true)
|
154
|
+
issue.save!
|
155
|
+
issue.jira_key.should == 'EX-2'
|
156
|
+
issue.comments.comments.count.should == 0
|
157
|
+
issue.watchers.watchers.count.should == 1
|
158
|
+
end
|
159
|
+
|
160
|
+
it "creates a new issue thgrough load without reload" do
|
161
|
+
hash = {"fields" => {"project" => {"id" => "10000"},
|
162
|
+
"summary" => "this is a test of creating a scratch ticket",
|
163
|
+
"issuetype" => {"id" => "7"},
|
164
|
+
"assignee" => {"name" => "stanley.handschuh"},
|
165
|
+
"priority" => {"id" => "1"},
|
166
|
+
"labels" => ["new_label_p"],
|
167
|
+
"environment" => "example of environment",
|
168
|
+
"description" => "example of the description extending"
|
169
|
+
}}
|
170
|
+
issue = Jiralicious::Issue.new
|
171
|
+
issue.load(hash)
|
172
|
+
issue.save!
|
173
|
+
issue.jira_key.should == 'EX-2'
|
174
|
+
issue.comments.comments.count.should == 0
|
175
|
+
issue.watchers.watchers.count.should == 1
|
176
|
+
end
|
177
|
+
|
178
|
+
it "creates a new issue through new" do
|
179
|
+
hash = {"project" => {"id" => "10000"},
|
180
|
+
"summary" => "this is a test of creating a scratch ticket",
|
181
|
+
"issuetype" => {"id" => "7"},
|
182
|
+
"assignee" => {"name" => "stanley.handschuh"},
|
183
|
+
"priority" => {"id" => "1"},
|
184
|
+
"labels" => ["new_label_p"],
|
185
|
+
"environment" => "example of environment",
|
186
|
+
"description" => "example of the description extending"
|
187
|
+
}
|
188
|
+
issue = Jiralicious::Issue.new(hash)
|
189
|
+
issue.save!
|
190
|
+
issue.jira_key.should == 'EX-2'
|
191
|
+
issue.comments.comments.count.should == 0
|
192
|
+
issue.watchers.watchers.count.should == 1
|
193
|
+
end
|
194
|
+
|
195
|
+
it "updates a new issue" do
|
196
|
+
issue = Jiralicious::Issue.find("EX-3")
|
197
|
+
issue.fields.append_a("labels", ["test_label"])
|
198
|
+
issue.fields.append_s("description", " updated description ")
|
199
|
+
issue.save
|
200
|
+
issue.jira_key.should == 'EX-3'
|
201
|
+
issue['fields']['labels'].should == ["test_label"]
|
202
|
+
issue['fields']['description'].should == "example bug report updated description "
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
#################################################################################################################
|
207
|
+
|
208
|
+
describe Jiralicious::Issue, "Managing Issues" do
|
209
|
+
|
210
|
+
before :each do
|
211
|
+
Jiralicious.configure do |config|
|
212
|
+
config.username = "jstewart"
|
213
|
+
config.password = "topsecret"
|
214
|
+
config.uri = "http://jstewart:topsecret@localhost"
|
215
|
+
config.auth_type = :basic
|
216
|
+
config.api_version = "latest"
|
217
|
+
end
|
218
|
+
|
219
|
+
FakeWeb.register_uri(:get,
|
220
|
+
"#{Jiralicious.rest_path}/issue/EX-1",
|
221
|
+
:status => "200",
|
222
|
+
:body => issue_json)
|
223
|
+
FakeWeb.register_uri(:delete,
|
224
|
+
"#{Jiralicious.rest_path}/issue/EX-1",
|
225
|
+
:status => "204")
|
226
|
+
FakeWeb.register_uri(:put,
|
227
|
+
"#{Jiralicious.rest_path}/issue/EX-1/assignee",
|
228
|
+
:status => "204")
|
229
|
+
FakeWeb.register_uri(:get,
|
230
|
+
"#{Jiralicious.rest_path}/issue/EX-1/comment/",
|
231
|
+
:status => "200",
|
232
|
+
:body => comment_json)
|
233
|
+
FakeWeb.register_uri(:get,
|
234
|
+
"#{Jiralicious.rest_path}/issue/EX-1/watchers/",
|
235
|
+
:status => "200",
|
236
|
+
:body => watchers_json)
|
237
|
+
end
|
238
|
+
|
239
|
+
it "update the assignee instance" do
|
240
|
+
issue = Jiralicious::Issue.find("EX-1")
|
241
|
+
response = issue.set_assignee("jira_admin")
|
242
|
+
response.response.class.should == Net::HTTPNoContent
|
243
|
+
end
|
244
|
+
|
245
|
+
it "update the assignee class" do
|
246
|
+
response = Jiralicious::Issue.assignee("jira_admin", "EX-1")
|
247
|
+
response.response.class.should == Net::HTTPNoContent
|
248
|
+
end
|
249
|
+
|
250
|
+
it "deletes the issue at the class level" do
|
251
|
+
response = Jiralicious::Issue.remove("EX-1")
|
252
|
+
response.response.class.should == Net::HTTPNoContent
|
253
|
+
end
|
254
|
+
|
255
|
+
it "deletes the issue at the instance level" do
|
256
|
+
issue = Jiralicious::Issue.find("EX-1")
|
257
|
+
response = issue.remove
|
258
|
+
response.response.class.should == Net::HTTPNoContent
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
#################################################################################################################
|
263
|
+
|
264
|
+
describe Jiralicious::Issue, "Issue Information and Field Class" do
|
265
|
+
|
266
|
+
before :each do
|
267
|
+
Jiralicious.configure do |config|
|
268
|
+
config.username = "jstewart"
|
269
|
+
config.password = "topsecret"
|
270
|
+
config.uri = "http://jstewart:topsecret@localhost"
|
271
|
+
config.auth_type = :basic
|
272
|
+
config.api_version = "latest"
|
273
|
+
end
|
274
|
+
|
275
|
+
FakeWeb.register_uri(:get,
|
276
|
+
"#{Jiralicious.rest_path}/issue/createmeta?projectKeys=EX&expand=projects.issuetypes.fields.&issuetypeIds=",
|
277
|
+
:status => "200",
|
278
|
+
:body => issue_createmeta_json)
|
279
|
+
FakeWeb.register_uri(:get,
|
280
|
+
"#{Jiralicious.rest_path}/issue/EX-1/editmeta",
|
281
|
+
:status => "200",
|
282
|
+
:body => issue_editmeta_json)
|
283
|
+
FakeWeb.register_uri(:get,
|
284
|
+
"#{Jiralicious.rest_path}/issue/EX-1",
|
285
|
+
:status => "200",
|
286
|
+
:body => issue_json)
|
287
|
+
FakeWeb.register_uri(:get,
|
288
|
+
"#{Jiralicious.rest_path}/issue/EX-1/comment/",
|
289
|
+
:status => "200",
|
290
|
+
:body => comment_json)
|
291
|
+
FakeWeb.register_uri(:get,
|
292
|
+
"#{Jiralicious.rest_path}/issue/EX-1/watchers/",
|
293
|
+
:status => "200",
|
294
|
+
:body => watchers_json)
|
295
|
+
end
|
296
|
+
|
297
|
+
it "retrieve createmeta for project class level" do
|
298
|
+
meta = Jiralicious::Issue.createmeta("EX")
|
299
|
+
meta.class.should == Jiralicious::Field
|
300
|
+
meta.projects[0].key.should == "EX"
|
301
|
+
end
|
302
|
+
|
303
|
+
it "retrieve createmeta for project instance level" do
|
304
|
+
issue = Jiralicious::Issue.find("EX-1")
|
305
|
+
meta = issue.createmeta
|
306
|
+
meta.class.should == Jiralicious::Field
|
307
|
+
meta.projects[0].key.should == "EX"
|
308
|
+
end
|
309
|
+
|
310
|
+
it "retrieve editmeta for project class level" do
|
311
|
+
meta = Jiralicious::Issue.editmeta("EX-1")
|
312
|
+
meta.class.should == Jiralicious::Field
|
313
|
+
meta.key.should == "EX-1"
|
314
|
+
meta.fields.summary.required.should == false
|
315
|
+
end
|
316
|
+
|
317
|
+
it "retrieve editmeta for project instance level" do
|
318
|
+
issue = Jiralicious::Issue.find("EX-1")
|
319
|
+
meta = issue.editmeta
|
320
|
+
meta.class.should == Jiralicious::Field
|
321
|
+
meta.key.should == "EX-1"
|
322
|
+
meta.jira_key.should == "EX-1"
|
323
|
+
meta.fields.summary.required.should == false
|
324
|
+
end
|
325
|
+
|
326
|
+
end
|
327
|
+
|
328
|
+
#################################################################################################################
|
329
|
+
|
330
|
+
describe Jiralicious::Issue, "transitions" do
|
331
|
+
|
332
|
+
before :each do
|
333
|
+
Jiralicious.configure do |config|
|
334
|
+
config.username = "jstewart"
|
335
|
+
config.password = "topsecret"
|
336
|
+
config.uri = "http://jstewart:topsecret@localhost"
|
337
|
+
config.auth_type = :basic
|
338
|
+
config.api_version = "latest"
|
339
|
+
end
|
340
|
+
|
341
|
+
end
|
342
|
+
|
343
|
+
it "returns list of possible transitions" do
|
344
|
+
FakeWeb.register_uri(:get,
|
345
|
+
"#{Jiralicious.rest_path}/issue/EX-1/transitions",
|
346
|
+
:status => "200",
|
347
|
+
:body => transitions_json)
|
348
|
+
|
349
|
+
transitions = Jiralicious::Issue.get_transitions("#{Jiralicious.rest_path}/issue/EX-1/transitions")
|
350
|
+
transitions.should be_instance_of(Hash)
|
351
|
+
end
|
352
|
+
|
353
|
+
it "performs transition" do
|
354
|
+
FakeWeb.register_uri(:post,
|
355
|
+
"#{Jiralicious.rest_path}/issue/EX-1/transitions",
|
356
|
+
:status => "204",
|
357
|
+
:body => nil)
|
358
|
+
|
359
|
+
result = Jiralicious::Issue.transition("#{Jiralicious.rest_path}/issue/EX-1/transitions",
|
360
|
+
{"transition" => "3", "fields" => []})
|
361
|
+
result.should be_nil
|
362
|
+
end
|
363
|
+
|
364
|
+
it "raises an exception on transition failure" do
|
365
|
+
FakeWeb.register_uri(:post,
|
366
|
+
"#{Jiralicious.rest_path}/issue/EX-1/transitions",
|
367
|
+
:status => "400",
|
368
|
+
:body => %q{{"errorMessages":["Workflow operation is not valid"],"errors":{}}})
|
369
|
+
lambda {
|
370
|
+
result = Jiralicious::Issue.transition("#{Jiralicious.rest_path}/issue/EX-1/transitions",
|
371
|
+
{"transition" => "invalid"})
|
372
|
+
}.should raise_error(Jiralicious::TransitionError)
|
373
|
+
end
|
374
|
+
|
375
|
+
it "raises an IssueNotFound exception if issue is not found" do
|
376
|
+
FakeWeb.register_uri(:post,
|
377
|
+
"#{Jiralicious.rest_path}/issue/EX-1/transitions",
|
378
|
+
:status => "404",
|
379
|
+
:body => %q{{"errorMessages":["Issue Does Not Exist"],"errors":{}}})
|
380
|
+
lambda {
|
381
|
+
result = Jiralicious::Issue.transition("#{Jiralicious.rest_path}/issue/EX-1/transitions",
|
382
|
+
{"transition" => "invalid"})
|
383
|
+
}.should raise_error(Jiralicious::IssueNotFound)
|
384
|
+
end
|
385
|
+
end
|