jiralicious 0.1.0 → 0.2.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.
Files changed (50) hide show
  1. data/.gitignore +2 -1
  2. data/.ruby-gemset +1 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +5 -0
  5. data/README.md +32 -4
  6. data/jiralicious.gemspec +7 -5
  7. data/lib/jiralicious.rb +10 -3
  8. data/lib/jiralicious/base.rb +114 -0
  9. data/lib/jiralicious/configuration.rb +13 -2
  10. data/lib/jiralicious/cookie_session.rb +5 -5
  11. data/lib/jiralicious/custom_field_option.rb +27 -0
  12. data/lib/jiralicious/field.rb +39 -0
  13. data/lib/jiralicious/issue.rb +111 -26
  14. data/lib/jiralicious/issue/comment.rb +62 -0
  15. data/lib/jiralicious/issue/fields.rb +93 -0
  16. data/lib/jiralicious/issue/transitions.rb +92 -0
  17. data/lib/jiralicious/issue/watchers.rb +47 -0
  18. data/lib/jiralicious/parsers/field_parser.rb +2 -2
  19. data/lib/jiralicious/project.rb +44 -0
  20. data/lib/jiralicious/search.rb +4 -1
  21. data/lib/jiralicious/search_result.rb +4 -0
  22. data/lib/jiralicious/version.rb +1 -1
  23. data/spec/basic_session_spec.rb +4 -4
  24. data/spec/comment_spec.rb +64 -0
  25. data/spec/configuration_spec.rb +9 -0
  26. data/spec/fixtures/comment.json +30 -0
  27. data/spec/fixtures/comment_single.json +29 -0
  28. data/spec/fixtures/issue.json +89 -93
  29. data/spec/fixtures/issue_2.json +30 -0
  30. data/spec/fixtures/issue_create.json +5 -0
  31. data/spec/fixtures/issue_createmeta.json +34 -0
  32. data/spec/fixtures/issue_editmeta.json +22 -0
  33. data/spec/fixtures/issue_update.json +164 -0
  34. data/spec/fixtures/jira.yml +7 -0
  35. data/spec/fixtures/project.json +87 -0
  36. data/spec/fixtures/project_issue_list.json +20 -0
  37. data/spec/fixtures/projects.json +22 -0
  38. data/spec/fixtures/search.json +9 -9
  39. data/spec/fixtures/test.json +24 -0
  40. data/spec/fixtures/transitions.json +61 -61
  41. data/spec/fixtures/watchers.json +17 -0
  42. data/spec/issue_spec.rb +255 -21
  43. data/spec/project_spec.rb +55 -0
  44. data/spec/search_result_spec.rb +20 -8
  45. data/spec/search_spec.rb +6 -6
  46. data/spec/support/http.rb +55 -2
  47. data/spec/watchers_spec.rb +43 -0
  48. metadata +154 -100
  49. data/.rvmrc +0 -1
  50. data/spec/cookie_session_spec.rb +0 -268
@@ -0,0 +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
@@ -0,0 +1,87 @@
1
+ {
2
+ "self": "http://www.example.com/jira/rest/api/2/project/EX",
3
+ "id": "10000",
4
+ "key": "EX",
5
+ "description": "This project was created as an example for REST.",
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
+ "components": [
17
+ {
18
+ "self": "http://www.example.com/jira/rest/api/2/component/10000",
19
+ "id": "10000",
20
+ "name": "Component 1",
21
+ "description": "This is a JIRA component",
22
+ "lead": {
23
+ "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
24
+ "name": "fred",
25
+ "avatarUrls": {
26
+ "16x16": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
27
+ "48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
28
+ },
29
+ "displayName": "Fred F. User",
30
+ "active": false
31
+ },
32
+ "assigneeType": "PROJECT_LEAD",
33
+ "assignee": {
34
+ "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
35
+ "name": "fred",
36
+ "avatarUrls": {
37
+ "16x16": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
38
+ "48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
39
+ },
40
+ "displayName": "Fred F. User",
41
+ "active": false
42
+ },
43
+ "realAssigneeType": "PROJECT_LEAD",
44
+ "realAssignee": {
45
+ "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
46
+ "name": "fred",
47
+ "avatarUrls": {
48
+ "16x16": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
49
+ "48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
50
+ },
51
+ "displayName": "Fred F. User",
52
+ "active": false
53
+ },
54
+ "isAssigneeTypeValid": false
55
+ }
56
+ ],
57
+ "issueTypes": [
58
+ {
59
+ "self": "http://localhost:8090/jira/rest/api/2.0/issueType/3",
60
+ "id": "3",
61
+ "description": "A task that needs to be done.",
62
+ "iconUrl": "http://localhost:8090/jira/images/icons/issuetypes/task.png",
63
+ "name": "Task",
64
+ "subtask": false
65
+ },
66
+ {
67
+ "self": "http://localhost:8090/jira/rest/api/2.0/issueType/1",
68
+ "id": "1",
69
+ "description": "A problem with the software.",
70
+ "iconUrl": "http://localhost:8090/jira/images/icons/issuetypes/bug.png",
71
+ "name": "Bug",
72
+ "subtask": false
73
+ }
74
+ ],
75
+ "url": "http://www.example.com/jira/browse/EX",
76
+ "email": "from-jira@example.com",
77
+ "assigneeType": "PROJECT_LEAD",
78
+ "versions": [],
79
+ "name": "Example",
80
+ "roles": {
81
+ "Developers": "http://www.example.com/jira/rest/api/2/project/EX/role/10000"
82
+ },
83
+ "avatarUrls": {
84
+ "16x16": "http://www.example.com/jira/secure/projectavatar?size=small&pid=10000",
85
+ "48x48": "http://www.example.com/jira/secure/projectavatar?size=large&pid=10000"
86
+ }
87
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "expand": "schema,names",
3
+ "startAt": 0,
4
+ "maxResults": 50,
5
+ "total": 2,
6
+ "issues": [
7
+ {
8
+ "expand": "editmeta,renderedFields,transitions,changelog,operations",
9
+ "id": "10000",
10
+ "self": "http://www.example.com/jira/rest/api/2/issue/10324",
11
+ "key": "EX-1"
12
+ },
13
+ {
14
+ "expand": "editmeta,renderedFields,transitions,changelog,operations",
15
+ "id": "10001",
16
+ "self": "http://www.example.com/jira/rest/api/2/issue/10323",
17
+ "key": "EX-2"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,22 @@
1
+ [
2
+ {
3
+ "self": "http://www.example.com/jira/rest/api/2/project/EX",
4
+ "id": "10000",
5
+ "key": "EX",
6
+ "name": "Example",
7
+ "avatarUrls": {
8
+ "16x16": "http://www.example.com/jira/secure/projectavatar?size=small&pid=10000",
9
+ "48x48": "http://www.example.com/jira/secure/projectavatar?size=large&pid=10000"
10
+ }
11
+ },
12
+ {
13
+ "self": "http://www.example.com/jira/rest/api/2/project/ABC",
14
+ "id": "10001",
15
+ "key": "ABC",
16
+ "name": "Alphabetical",
17
+ "avatarUrls": {
18
+ "16x16": "http://www.example.com/jira/secure/projectavatar?size=small&pid=10001",
19
+ "48x48": "http://www.example.com/jira/secure/projectavatar?size=large&pid=10001"
20
+ }
21
+ }
22
+ ]
@@ -1,11 +1,11 @@
1
1
  {
2
- "startAt": 0,
3
- "maxResults": 50,
4
- "total": 1,
5
- "issues": [
6
- {
7
- "self": "http://www.example.com/jira/rest/api/2.0/jira/rest/api/2.0/issue/HSP-1",
8
- "key": "HSP-1"
9
- }
10
- ]
2
+ "startAt": 0,
3
+ "maxResults": 50,
4
+ "total": 1,
5
+ "issues": [
6
+ {
7
+ "self": "http://www.example.com/jira/rest/api/2.0/jira/rest/api/2.0/issue/HSP-1",
8
+ "key": "HSP-1"
9
+ }
10
+ ]
11
11
  }
@@ -0,0 +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"}
24
+ updated="2013-04-10T08:38:17.000-0500">
@@ -1,65 +1,65 @@
1
1
  {
2
- "2": {
3
- "name": "Close Issue",
4
- "fields": [{
5
- "id": "resolution",
6
- "required": true,
7
- "type": "com.atlassian.jira.issue.resolution.Resolution"
8
- },
9
- {
10
- "id": "fixVersions",
11
- "required": false,
12
- "type": "com.atlassian.jira.project.version.Version"
13
- },
14
- {
15
- "id": "customfield_10105",
16
- "required": false,
17
- "type": "com.atlassian.jira.plugins.jira-importers-plugin:bug-importid"
18
- },
19
- {
20
- "id": "customfield_10106",
21
- "required": false,
22
- "type": "com.atlassian.jira.plugin.system.customfieldtypes:textfield"
23
- },
24
- {
25
- "id": "assignee",
26
- "required": false,
27
- "type": "com.opensymphony.user.User"
28
- }],
29
- "transitionDestination": "6"
2
+ "2": {
3
+ "name": "Close Issue",
4
+ "fields": [{
5
+ "id": "resolution",
6
+ "required": true,
7
+ "type": "com.atlassian.jira.issue.resolution.Resolution"
30
8
  },
31
- "4": {
32
- "name": "Start Progress",
33
- "fields": [],
34
- "transitionDestination": "3"
9
+ {
10
+ "id": "fixVersions",
11
+ "required": false,
12
+ "type": "com.atlassian.jira.project.version.Version"
35
13
  },
36
- "5": {
37
- "name": "Resolve Issue",
38
- "fields": [{
39
- "id": "resolution",
40
- "required": true,
41
- "type": "com.atlassian.jira.issue.resolution.Resolution"
42
- },
43
- {
44
- "id": "fixVersions",
45
- "required": false,
46
- "type": "com.atlassian.jira.project.version.Version"
47
- },
48
- {
49
- "id": "customfield_10105",
50
- "required": false,
51
- "type": "com.atlassian.jira.plugins.jira-importers-plugin:bug-importid"
52
- },
53
- {
54
- "id": "customfield_10106",
55
- "required": false,
56
- "type": "com.atlassian.jira.plugin.system.customfieldtypes:textfield"
57
- },
58
- {
59
- "id": "assignee",
60
- "required": false,
61
- "type": "com.opensymphony.user.User"
62
- }],
63
- "transitionDestination": "5"
64
- }
14
+ {
15
+ "id": "customfield_10105",
16
+ "required": false,
17
+ "type": "com.atlassian.jira.plugins.jira-importers-plugin:bug-importid"
18
+ },
19
+ {
20
+ "id": "customfield_10106",
21
+ "required": false,
22
+ "type": "com.atlassian.jira.plugin.system.customfieldtypes:textfield"
23
+ },
24
+ {
25
+ "id": "assignee",
26
+ "required": false,
27
+ "type": "com.opensymphony.user.User"
28
+ }],
29
+ "transitionDestination": "6"
30
+ },
31
+ "4": {
32
+ "name": "Start Progress",
33
+ "fields": [],
34
+ "transitionDestination": "3"
35
+ },
36
+ "5": {
37
+ "name": "Resolve Issue",
38
+ "fields": [{
39
+ "id": "resolution",
40
+ "required": true,
41
+ "type": "com.atlassian.jira.issue.resolution.Resolution"
42
+ },
43
+ {
44
+ "id": "fixVersions",
45
+ "required": false,
46
+ "type": "com.atlassian.jira.project.version.Version"
47
+ },
48
+ {
49
+ "id": "customfield_10105",
50
+ "required": false,
51
+ "type": "com.atlassian.jira.plugins.jira-importers-plugin:bug-importid"
52
+ },
53
+ {
54
+ "id": "customfield_10106",
55
+ "required": false,
56
+ "type": "com.atlassian.jira.plugin.system.customfieldtypes:textfield"
57
+ },
58
+ {
59
+ "id": "assignee",
60
+ "required": false,
61
+ "type": "com.opensymphony.user.User"
62
+ }],
63
+ "transitionDestination": "5"
64
+ }
65
65
  }
@@ -0,0 +1,17 @@
1
+ {
2
+ "self": "http://www.example.com/rest/api/2/issue/DEMO-10/watchers",
3
+ "isWatching": true,
4
+ "watchCount": 1,
5
+ "watchers": [
6
+ {
7
+ "self": "http://www.example.com/rest/api/2/user?username=jira_admin",
8
+ "name": "fred",
9
+ "avatarUrls": {
10
+ "16x16": "http://www.example.com/secure/useravatar?size=small&avatarId=10122",
11
+ "48x48": "http://www.example.com/secure/useravatar?avatarId=10122"
12
+ },
13
+ "displayName": "fred",
14
+ "active": true
15
+ }
16
+ ]
17
+ }
data/spec/issue_spec.rb CHANGED
@@ -13,9 +13,17 @@ describe Jiralicious::Issue, "finding" do
13
13
  end
14
14
 
15
15
  FakeWeb.register_uri(:get,
16
- "#{Jiralicious.rest_path}/issue/EX-1",
17
- :status => "200",
18
- :body => issue_json)
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)
19
27
  end
20
28
 
21
29
  it "finds the issue by key" do
@@ -26,9 +34,9 @@ describe Jiralicious::Issue, "finding" do
26
34
  it "raises an exception when the issue can't be found or can't be viewed" do
27
35
  lambda {
28
36
  FakeWeb.register_uri(:get,
29
- "#{Jiralicious.rest_path}/issue/EX-1",
30
- :body => "{errorMessages: ['error']}",
31
- :status => ["404" "Not Found"])
37
+ "#{Jiralicious.rest_path}/issue/EX-1",
38
+ :body => '{"errorMessages": ["error"]}',
39
+ :status => ["404" "Not Found"])
32
40
  Jiralicious::Issue.find("EX-1")
33
41
  }.should raise_error(Jiralicious::IssueNotFound)
34
42
  end
@@ -40,6 +48,232 @@ describe Jiralicious::Issue, "finding" do
40
48
  end
41
49
  end
42
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://localhost"
60
+ config.auth_type = :cookie
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
+
127
+ it "creates a new issue" do
128
+ issue = Jiralicious::Issue.new
129
+ issue.fields.set_id("project", "10000")
130
+ issue.fields.set("summary", "this is a test of creating a scratch ticket")
131
+ issue.fields.set_id("issuetype", "7")
132
+ issue.fields.set_name("assignee", "stanley.handschuh")
133
+ issue.fields.set_id("priority", "1")
134
+ issue.fields.set("labels", ["new_label_p"])
135
+ issue.fields.set("environment", "example of environment")
136
+ issue.fields.set("description", "example of the description extending")
137
+ issue.save
138
+ issue.jira_key.should == 'EX-2'
139
+ issue.comments.comments.count.should == 0
140
+ issue.watchers.watchers.count.should == 1
141
+ end
142
+
143
+ it "updates a new issue" do
144
+ issue = Jiralicious::Issue.find("EX-3")
145
+ issue.fields.append_a("labels", "test_label")
146
+ issue.fields.append_s("description", " updated description ")
147
+ issue.save
148
+ issue.jira_key.should == 'EX-3'
149
+ issue['fields']['labels'].should == ["test_label"]
150
+ issue['fields']['description'].should == "example bug report updated description "
151
+ end
152
+ end
153
+
154
+ #################################################################################################################
155
+
156
+ describe Jiralicious::Issue, "Managing Issues" do
157
+
158
+ before :each do
159
+ Jiralicious.configure do |config|
160
+ config.username = "jstewart"
161
+ config.password = "topsecret"
162
+ config.uri = "http://localhost"
163
+ config.auth_type = :cookie
164
+ config.api_version = "latest"
165
+ end
166
+
167
+ FakeWeb.register_uri(:get,
168
+ "#{Jiralicious.rest_path}/issue/EX-1",
169
+ :status => "200",
170
+ :body => issue_json)
171
+ FakeWeb.register_uri(:delete,
172
+ "#{Jiralicious.rest_path}/issue/EX-1",
173
+ :status => "204")
174
+ FakeWeb.register_uri(:put,
175
+ "#{Jiralicious.rest_path}/issue/EX-1/assignee",
176
+ :status => "204")
177
+ FakeWeb.register_uri(:get,
178
+ "#{Jiralicious.rest_path}/issue/EX-1/comment/",
179
+ :status => "200",
180
+ :body => comment_json)
181
+ FakeWeb.register_uri(:get,
182
+ "#{Jiralicious.rest_path}/issue/EX-1/watchers/",
183
+ :status => "200",
184
+ :body => watchers_json)
185
+ end
186
+
187
+ it "update the assignee instance" do
188
+ issue = Jiralicious::Issue.find("EX-1")
189
+ response = issue.set_assignee("jira_admin")
190
+ response.response.class.should == Net::HTTPNoContent
191
+ end
192
+
193
+ it "update the assignee class" do
194
+ response = Jiralicious::Issue.assignee("jira_admin", "EX-1")
195
+ response.response.class.should == Net::HTTPNoContent
196
+ end
197
+
198
+ it "deletes the issue at the class level" do
199
+ response = Jiralicious::Issue.remove("EX-1")
200
+ response.response.class.should == Net::HTTPNoContent
201
+ end
202
+
203
+ it "deletes the issue at the instance level" do
204
+ issue = Jiralicious::Issue.find("EX-1")
205
+ response = issue.remove
206
+ response.response.class.should == Net::HTTPNoContent
207
+ end
208
+ end
209
+
210
+ #################################################################################################################
211
+
212
+ describe Jiralicious::Issue, "Issue Information and Field Class" do
213
+
214
+ before :each do
215
+ Jiralicious.configure do |config|
216
+ config.username = "jstewart"
217
+ config.password = "topsecret"
218
+ config.uri = "http://localhost"
219
+ config.auth_type = :cookie
220
+ config.api_version = "latest"
221
+ end
222
+
223
+ FakeWeb.register_uri(:get,
224
+ "#{Jiralicious.rest_path}/issue/createmeta?projectKeys=EX&expand=projects.issuetypes.fields.&issuetypeIds=",
225
+ :status => "200",
226
+ :body => issue_createmeta_json)
227
+ FakeWeb.register_uri(:get,
228
+ "#{Jiralicious.rest_path}/issue/EX-1/editmeta",
229
+ :status => "200",
230
+ :body => issue_editmeta_json)
231
+ FakeWeb.register_uri(:get,
232
+ "#{Jiralicious.rest_path}/issue/EX-1",
233
+ :status => "200",
234
+ :body => issue_json)
235
+ FakeWeb.register_uri(:get,
236
+ "#{Jiralicious.rest_path}/issue/EX-1/comment/",
237
+ :status => "200",
238
+ :body => comment_json)
239
+ FakeWeb.register_uri(:get,
240
+ "#{Jiralicious.rest_path}/issue/EX-1/watchers/",
241
+ :status => "200",
242
+ :body => watchers_json)
243
+ end
244
+
245
+ it "retrieve createmeta for project class level" do
246
+ meta = Jiralicious::Issue.createmeta("EX")
247
+ meta.class.should == Jiralicious::Field
248
+ meta.projects[0].key.should == "EX"
249
+ end
250
+
251
+ it "retrieve createmeta for project instance level" do
252
+ issue = Jiralicious::Issue.find("EX-1")
253
+ meta = issue.createmeta
254
+ meta.class.should == Jiralicious::Field
255
+ meta.projects[0].key.should == "EX"
256
+ end
257
+
258
+ it "retrieve editmeta for project class level" do
259
+ meta = Jiralicious::Issue.editmeta("EX-1")
260
+ meta.class.should == Jiralicious::Field
261
+ meta.key.should == "EX-1"
262
+ meta.fields.summary.required.should == false
263
+ end
264
+
265
+ it "retrieve editmeta for project instance level" do
266
+ issue = Jiralicious::Issue.find("EX-1")
267
+ meta = issue.editmeta
268
+ meta.class.should == Jiralicious::Field
269
+ meta.key.should == "EX-1"
270
+ meta.jira_key.should == "EX-1"
271
+ meta.fields.summary.required.should == false
272
+ end
273
+
274
+ end
275
+
276
+ #################################################################################################################
43
277
 
44
278
  describe Jiralicious::Issue, "transitions" do
45
279
 
@@ -55,9 +289,9 @@ describe Jiralicious::Issue, "transitions" do
55
289
 
56
290
  it "returns list of possible transitions" do
57
291
  FakeWeb.register_uri(:get,
58
- "#{Jiralicious.rest_path}/issue/EX-1/transitions",
59
- :status => "200",
60
- :body => transitions_json)
292
+ "#{Jiralicious.rest_path}/issue/EX-1/transitions",
293
+ :status => "200",
294
+ :body => transitions_json)
61
295
 
62
296
  transitions = Jiralicious::Issue.get_transitions("#{Jiralicious.rest_path}/issue/EX-1/transitions")
63
297
  transitions.should be_instance_of(Hash)
@@ -65,34 +299,34 @@ describe Jiralicious::Issue, "transitions" do
65
299
 
66
300
  it "performs transition" do
67
301
  FakeWeb.register_uri(:post,
68
- "#{Jiralicious.rest_path}/issue/EX-1/transitions",
69
- :status => "204",
70
- :body => nil)
302
+ "#{Jiralicious.rest_path}/issue/EX-1/transitions",
303
+ :status => "204",
304
+ :body => nil)
71
305
 
72
306
  result = Jiralicious::Issue.transition("#{Jiralicious.rest_path}/issue/EX-1/transitions",
73
- {"transition" => "3", "fields" => []})
307
+ {"transition" => "3", "fields" => []})
74
308
  result.should be_nil
75
309
  end
76
310
 
77
311
  it "raises an exception on transition failure" do
78
312
  FakeWeb.register_uri(:post,
79
- "#{Jiralicious.rest_path}/issue/EX-1/transitions",
80
- :status => "400",
81
- :body => %q{{"errorMessages":["Workflow operation is not valid"],"errors":{}}})
313
+ "#{Jiralicious.rest_path}/issue/EX-1/transitions",
314
+ :status => "400",
315
+ :body => %q{{"errorMessages":["Workflow operation is not valid"],"errors":{}}})
82
316
  lambda {
83
317
  result = Jiralicious::Issue.transition("#{Jiralicious.rest_path}/issue/EX-1/transitions",
84
- {"transition" => "invalid"})
318
+ {"transition" => "invalid"})
85
319
  }.should raise_error(Jiralicious::TransitionError)
86
320
  end
87
321
 
88
322
  it "raises an IssueNotFound exception if issue is not found" do
89
323
  FakeWeb.register_uri(:post,
90
- "#{Jiralicious.rest_path}/issue/EX-1/transitions",
91
- :status => "404",
92
- :body => %q{{"errorMessages":["Issue Does Not Exist"],"errors":{}}})
324
+ "#{Jiralicious.rest_path}/issue/EX-1/transitions",
325
+ :status => "404",
326
+ :body => %q{{"errorMessages":["Issue Does Not Exist"],"errors":{}}})
93
327
  lambda {
94
328
  result = Jiralicious::Issue.transition("#{Jiralicious.rest_path}/issue/EX-1/transitions",
95
- {"transition" => "invalid"})
329
+ {"transition" => "invalid"})
96
330
  }.should raise_error(Jiralicious::IssueNotFound)
97
331
  end
98
332
  end