jira-ruby 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/README.rdoc +259 -0
  2. data/Rakefile +9 -0
  3. data/example.rb +47 -4
  4. data/jira-ruby.gemspec +5 -3
  5. data/lib/jira.rb +21 -7
  6. data/lib/jira/base.rb +466 -0
  7. data/lib/jira/base_factory.rb +49 -0
  8. data/lib/jira/client.rb +79 -8
  9. data/lib/jira/has_many_proxy.rb +43 -0
  10. data/lib/jira/http_error.rb +16 -0
  11. data/lib/jira/resource/attachment.rb +12 -0
  12. data/lib/jira/resource/comment.rb +14 -0
  13. data/lib/jira/resource/component.rb +4 -9
  14. data/lib/jira/resource/issue.rb +49 -5
  15. data/lib/jira/resource/issuetype.rb +10 -0
  16. data/lib/jira/resource/priority.rb +10 -0
  17. data/lib/jira/resource/project.rb +24 -3
  18. data/lib/jira/resource/status.rb +10 -0
  19. data/lib/jira/resource/user.rb +14 -0
  20. data/lib/jira/resource/version.rb +10 -0
  21. data/lib/jira/resource/worklog.rb +16 -0
  22. data/lib/jira/version.rb +2 -2
  23. data/spec/integration/attachment_spec.rb +26 -0
  24. data/spec/integration/comment_spec.rb +55 -0
  25. data/spec/integration/component_spec.rb +25 -52
  26. data/spec/integration/issue_spec.rb +50 -47
  27. data/spec/integration/issuetype_spec.rb +27 -0
  28. data/spec/integration/priority_spec.rb +27 -0
  29. data/spec/integration/project_spec.rb +32 -24
  30. data/spec/integration/status_spec.rb +27 -0
  31. data/spec/integration/user_spec.rb +25 -0
  32. data/spec/integration/version_spec.rb +43 -0
  33. data/spec/integration/worklog_spec.rb +55 -0
  34. data/spec/jira/base_factory_spec.rb +46 -0
  35. data/spec/jira/base_spec.rb +555 -0
  36. data/spec/jira/client_spec.rb +12 -12
  37. data/spec/jira/has_many_proxy_spec.rb +45 -0
  38. data/spec/jira/{resource/http_error_spec.rb → http_error_spec.rb} +1 -1
  39. data/spec/jira/resource/attachment_spec.rb +20 -0
  40. data/spec/jira/resource/issue_spec.rb +83 -0
  41. data/spec/jira/resource/project_factory_spec.rb +3 -3
  42. data/spec/jira/resource/project_spec.rb +28 -0
  43. data/spec/jira/resource/worklog_spec.rb +24 -0
  44. data/spec/mock_responses/attachment/10000.json +20 -0
  45. data/spec/mock_responses/component/10000.invalid.put.json +5 -0
  46. data/spec/mock_responses/issue.json +1108 -0
  47. data/spec/mock_responses/issue/10002.invalid.put.json +6 -0
  48. data/spec/mock_responses/issue/10002.json +13 -1
  49. data/spec/mock_responses/issue/10002.put.missing_field_update.json +6 -0
  50. data/spec/mock_responses/issue/10002/comment.json +65 -0
  51. data/spec/mock_responses/issue/10002/comment.post.json +29 -0
  52. data/spec/mock_responses/issue/10002/comment/10000.json +29 -0
  53. data/spec/mock_responses/issue/10002/comment/10000.put.json +29 -0
  54. data/spec/mock_responses/issue/10002/worklog.json +98 -0
  55. data/spec/mock_responses/issue/10002/worklog.post.json +30 -0
  56. data/spec/mock_responses/issue/10002/worklog/10000.json +31 -0
  57. data/spec/mock_responses/issue/10002/worklog/10000.put.json +30 -0
  58. data/spec/mock_responses/issuetype.json +42 -0
  59. data/spec/mock_responses/issuetype/5.json +8 -0
  60. data/spec/mock_responses/priority.json +42 -0
  61. data/spec/mock_responses/priority/1.json +8 -0
  62. data/spec/mock_responses/project/SAMPLEPROJECT.issues.json +1108 -0
  63. data/spec/mock_responses/project/SAMPLEPROJECT.json +15 -1
  64. data/spec/mock_responses/status.json +37 -0
  65. data/spec/mock_responses/status/1.json +7 -0
  66. data/spec/mock_responses/user?username=admin.json +17 -0
  67. data/spec/mock_responses/version.post.json +7 -0
  68. data/spec/mock_responses/version/10000.invalid.put.json +5 -0
  69. data/spec/mock_responses/version/10000.json +11 -0
  70. data/spec/mock_responses/version/10000.put.json +7 -0
  71. data/spec/spec_helper.rb +7 -12
  72. data/spec/support/matchers/have_attributes.rb +11 -0
  73. data/spec/support/matchers/have_many.rb +9 -0
  74. data/spec/support/matchers/have_one.rb +5 -0
  75. data/spec/support/shared_examples/integration.rb +174 -0
  76. metadata +139 -24
  77. data/README.markdown +0 -81
  78. data/lib/jira/resource/base.rb +0 -148
  79. data/lib/jira/resource/base_factory.rb +0 -44
  80. data/lib/jira/resource/http_error.rb +0 -17
  81. data/spec/jira/resource/base_factory_spec.rb +0 -36
  82. data/spec/jira/resource/base_spec.rb +0 -292
@@ -0,0 +1,6 @@
1
+ {
2
+ "errorMessages": [],
3
+ "errors": {
4
+ "invalid": "Field 'invalid' is not valid for this operation."
5
+ }
6
+ }
@@ -101,7 +101,19 @@
101
101
  "progress": 0,
102
102
  "total": 0
103
103
  },
104
- "components": [],
104
+ "components": [
105
+ {
106
+ "self": "http://localhost:2990/jira/rest/api/2/component/10001",
107
+ "id": "10001",
108
+ "name": "Jamflam"
109
+ },
110
+ {
111
+ "self": "http://localhost:2990/jira/rest/api/2/component/10000",
112
+ "id": "10000",
113
+ "name": "Jammy",
114
+ "description": "Description!"
115
+ }
116
+ ],
105
117
  "comment": {
106
118
  "startAt": 0,
107
119
  "maxResults": 0,
@@ -0,0 +1,6 @@
1
+ {
2
+ "errorMessages": [
3
+ "one of 'fields' or 'update' required"
4
+ ],
5
+ "errors": {}
6
+ }
@@ -0,0 +1,65 @@
1
+ {
2
+ "startAt": 0,
3
+ "maxResults": 2,
4
+ "total": 2,
5
+ "comments": [
6
+ {
7
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10002/comment/10000",
8
+ "id": "10000",
9
+ "author": {
10
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
11
+ "name": "admin",
12
+ "emailAddress": "admin@example.com",
13
+ "avatarUrls": {
14
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
15
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
16
+ },
17
+ "displayName": "admin",
18
+ "active": true
19
+ },
20
+ "body": "This is a comment. Creative.",
21
+ "updateAuthor": {
22
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
23
+ "name": "admin",
24
+ "emailAddress": "admin@example.com",
25
+ "avatarUrls": {
26
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
27
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
28
+ },
29
+ "displayName": "admin",
30
+ "active": true
31
+ },
32
+ "created": "2012-01-11T10:02:14.430+1300",
33
+ "updated": "2012-01-12T15:15:13.074+1300"
34
+ },
35
+ {
36
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10002/comment/10001",
37
+ "id": "10001",
38
+ "author": {
39
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
40
+ "name": "admin",
41
+ "emailAddress": "admin@example.com",
42
+ "avatarUrls": {
43
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
44
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
45
+ },
46
+ "displayName": "admin",
47
+ "active": true
48
+ },
49
+ "body": "new comment",
50
+ "updateAuthor": {
51
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
52
+ "name": "admin",
53
+ "emailAddress": "admin@example.com",
54
+ "avatarUrls": {
55
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
56
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
57
+ },
58
+ "displayName": "admin",
59
+ "active": true
60
+ },
61
+ "created": "2012-01-12T14:29:59.209+1300",
62
+ "updated": "2012-01-12T14:29:59.209+1300"
63
+ }
64
+ ]
65
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10002/comment/10001",
3
+ "id": "10001",
4
+ "author": {
5
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
6
+ "name": "admin",
7
+ "emailAddress": "admin@example.com",
8
+ "avatarUrls": {
9
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
10
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
11
+ },
12
+ "displayName": "admin",
13
+ "active": true
14
+ },
15
+ "body": "new comment",
16
+ "updateAuthor": {
17
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
18
+ "name": "admin",
19
+ "emailAddress": "admin@example.com",
20
+ "avatarUrls": {
21
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
22
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
23
+ },
24
+ "displayName": "admin",
25
+ "active": true
26
+ },
27
+ "created": "2012-01-12T14:29:59.209+1300",
28
+ "updated": "2012-01-12T14:29:59.209+1300"
29
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10002/comment/10000",
3
+ "id": "10000",
4
+ "author": {
5
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
6
+ "name": "admin",
7
+ "emailAddress": "admin@example.com",
8
+ "avatarUrls": {
9
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
10
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
11
+ },
12
+ "displayName": "admin",
13
+ "active": true
14
+ },
15
+ "body": "This is a comment. Creative.",
16
+ "updateAuthor": {
17
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
18
+ "name": "admin",
19
+ "emailAddress": "admin@example.com",
20
+ "avatarUrls": {
21
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
22
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
23
+ },
24
+ "displayName": "admin",
25
+ "active": true
26
+ },
27
+ "created": "2012-01-11T10:02:14.430+1300",
28
+ "updated": "2012-01-11T10:02:14.430+1300"
29
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10002/comment/10000",
3
+ "id": "10000",
4
+ "author": {
5
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
6
+ "name": "admin",
7
+ "emailAddress": "admin@example.com",
8
+ "avatarUrls": {
9
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
10
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
11
+ },
12
+ "displayName": "admin",
13
+ "active": true
14
+ },
15
+ "body": "new body",
16
+ "updateAuthor": {
17
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
18
+ "name": "admin",
19
+ "emailAddress": "admin@example.com",
20
+ "avatarUrls": {
21
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
22
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
23
+ },
24
+ "displayName": "admin",
25
+ "active": true
26
+ },
27
+ "created": "2012-01-11T10:02:14.430+1300",
28
+ "updated": "2012-01-12T14:37:41.933+1300"
29
+ }
@@ -0,0 +1,98 @@
1
+ {
2
+ "startAt": 0,
3
+ "maxResults": 3,
4
+ "total": 3,
5
+ "worklogs": [
6
+ {
7
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10002/worklog/10000",
8
+ "author": {
9
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
10
+ "name": "admin",
11
+ "emailAddress": "admin@example.com",
12
+ "avatarUrls": {
13
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
14
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
15
+ },
16
+ "displayName": "admin",
17
+ "active": true
18
+ },
19
+ "updateAuthor": {
20
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
21
+ "name": "admin",
22
+ "emailAddress": "admin@example.com",
23
+ "avatarUrls": {
24
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
25
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
26
+ },
27
+ "displayName": "admin",
28
+ "active": true
29
+ },
30
+ "comment": "Some epic work.",
31
+ "created": "2012-01-11T13:33:25.604+1300",
32
+ "updated": "2012-01-11T13:33:25.604+1300",
33
+ "started": "2012-01-11T13:33:00.000+1300",
34
+ "timeSpent": "18w 2d",
35
+ "id": "10000"
36
+ },
37
+ {
38
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10002/worklog/10001",
39
+ "author": {
40
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
41
+ "name": "admin",
42
+ "emailAddress": "admin@example.com",
43
+ "avatarUrls": {
44
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
45
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
46
+ },
47
+ "displayName": "admin",
48
+ "active": true
49
+ },
50
+ "updateAuthor": {
51
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
52
+ "name": "admin",
53
+ "emailAddress": "admin@example.com",
54
+ "avatarUrls": {
55
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
56
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
57
+ },
58
+ "displayName": "admin",
59
+ "active": true
60
+ },
61
+ "created": "2012-01-12T16:08:58.529+1300",
62
+ "updated": "2012-01-12T16:11:22.266+1300",
63
+ "started": "2012-01-12T16:08:58.529+1300",
64
+ "timeSpent": "4d",
65
+ "id": "10001"
66
+ },
67
+ {
68
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10002/worklog/10002",
69
+ "author": {
70
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
71
+ "name": "admin",
72
+ "emailAddress": "admin@example.com",
73
+ "avatarUrls": {
74
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
75
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
76
+ },
77
+ "displayName": "admin",
78
+ "active": true
79
+ },
80
+ "updateAuthor": {
81
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
82
+ "name": "admin",
83
+ "emailAddress": "admin@example.com",
84
+ "avatarUrls": {
85
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
86
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
87
+ },
88
+ "displayName": "admin",
89
+ "active": true
90
+ },
91
+ "created": "2012-01-12T16:20:39.542+1300",
92
+ "updated": "2012-01-12T16:20:39.542+1300",
93
+ "started": "2012-01-12T16:20:39.541+1300",
94
+ "timeSpent": "3d",
95
+ "id": "10002"
96
+ }
97
+ ]
98
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10002/worklog/10001",
3
+ "author": {
4
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
5
+ "name": "admin",
6
+ "emailAddress": "admin@example.com",
7
+ "avatarUrls": {
8
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
9
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
10
+ },
11
+ "displayName": "admin",
12
+ "active": true
13
+ },
14
+ "updateAuthor": {
15
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
16
+ "name": "admin",
17
+ "emailAddress": "admin@example.com",
18
+ "avatarUrls": {
19
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
20
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
21
+ },
22
+ "displayName": "admin",
23
+ "active": true
24
+ },
25
+ "created": "2012-01-12T16:08:58.529+1300",
26
+ "updated": "2012-01-12T16:08:58.529+1300",
27
+ "started": "2012-01-12T16:08:58.529+1300",
28
+ "timeSpent": "2d",
29
+ "id": "10001"
30
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10002/worklog/10000",
3
+ "author": {
4
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
5
+ "name": "admin",
6
+ "emailAddress": "admin@example.com",
7
+ "avatarUrls": {
8
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
9
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
10
+ },
11
+ "displayName": "admin",
12
+ "active": true
13
+ },
14
+ "updateAuthor": {
15
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
16
+ "name": "admin",
17
+ "emailAddress": "admin@example.com",
18
+ "avatarUrls": {
19
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
20
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
21
+ },
22
+ "displayName": "admin",
23
+ "active": true
24
+ },
25
+ "comment": "Some epic work.",
26
+ "created": "2012-01-11T13:33:25.604+1300",
27
+ "updated": "2012-01-11T13:33:25.604+1300",
28
+ "started": "2012-01-11T13:33:00.000+1300",
29
+ "timeSpent": "18w 2d",
30
+ "id": "10000"
31
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10002/worklog/10001",
3
+ "author": {
4
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
5
+ "name": "admin",
6
+ "emailAddress": "admin@example.com",
7
+ "avatarUrls": {
8
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
9
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
10
+ },
11
+ "displayName": "admin",
12
+ "active": true
13
+ },
14
+ "updateAuthor": {
15
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
16
+ "name": "admin",
17
+ "emailAddress": "admin@example.com",
18
+ "avatarUrls": {
19
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
20
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
21
+ },
22
+ "displayName": "admin",
23
+ "active": true
24
+ },
25
+ "created": "2012-01-12T16:08:58.529+1300",
26
+ "updated": "2012-01-12T16:11:22.266+1300",
27
+ "started": "2012-01-12T16:08:58.529+1300",
28
+ "timeSpent": "4d",
29
+ "id": "10001"
30
+ }
@@ -0,0 +1,42 @@
1
+ [
2
+ {
3
+ "self": "http://localhost:2990/jira/rest/api/2/issuetype/5",
4
+ "id": "5",
5
+ "description": "The sub-task of the issue",
6
+ "iconUrl": "http://localhost:2990/jira/images/icons/issue_subtask.gif",
7
+ "name": "Sub-task",
8
+ "subtask": true
9
+ },
10
+ {
11
+ "self": "http://localhost:2990/jira/rest/api/2/issuetype/4",
12
+ "id": "4",
13
+ "description": "An improvement or enhancement to an existing feature or task.",
14
+ "iconUrl": "http://localhost:2990/jira/images/icons/improvement.gif",
15
+ "name": "Improvement",
16
+ "subtask": false
17
+ },
18
+ {
19
+ "self": "http://localhost:2990/jira/rest/api/2/issuetype/3",
20
+ "id": "3",
21
+ "description": "A task that needs to be done.",
22
+ "iconUrl": "http://localhost:2990/jira/images/icons/task.gif",
23
+ "name": "Task",
24
+ "subtask": false
25
+ },
26
+ {
27
+ "self": "http://localhost:2990/jira/rest/api/2/issuetype/1",
28
+ "id": "1",
29
+ "description": "A problem which impairs or prevents the functions of the product.",
30
+ "iconUrl": "http://localhost:2990/jira/images/icons/bug.gif",
31
+ "name": "Bug",
32
+ "subtask": false
33
+ },
34
+ {
35
+ "self": "http://localhost:2990/jira/rest/api/2/issuetype/2",
36
+ "id": "2",
37
+ "description": "A new feature of the product, which has yet to be developed.",
38
+ "iconUrl": "http://localhost:2990/jira/images/icons/newfeature.gif",
39
+ "name": "New Feature",
40
+ "subtask": false
41
+ }
42
+ ]
@@ -0,0 +1,8 @@
1
+ {
2
+ "self": "http://localhost:2990/jira/rest/api/2/issuetype/5",
3
+ "id": "5",
4
+ "description": "The sub-task of the issue",
5
+ "iconUrl": "http://localhost:2990/jira/images/icons/issue_subtask.gif",
6
+ "name": "Sub-task",
7
+ "subtask": true
8
+ }