jira_client 1.0.0 → 1.0.1

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.
@@ -8,5 +8,9 @@ module JiraClient
8
8
  convert :update_author, JiraClient::User
9
9
  convert :created, lambda {|value| DateTime.parse(value)}
10
10
  convert :updated, lambda {|value| DateTime.parse(value)}
11
+
12
+ def to_s
13
+ body
14
+ end
11
15
  end
12
16
  end
@@ -2,16 +2,21 @@ require "jira_client/status"
2
2
  require "jira_client/timetracking"
3
3
  require "jira_client/project"
4
4
  require "jira_client/worklog"
5
+ require "jira_client/issue_type"
5
6
 
6
7
  module JiraClient
7
8
  class Issue < JiraClient::Base
8
- attr_reader :key, :description, :summary, :status, :timetracking, :project, :worklog, :comment
9
+ attr_reader :key, :description, :summary, :status, :timetracking, :project, :worklog, :comment, :issuetype, :subtasks
9
10
 
10
11
  convert :status, JiraClient::Status
11
12
  convert :timetracking, JiraClient::Timetracking
12
- convert :comment, JiraClient::Comment
13
+ convert :comment, lambda {|response| response[:comments].map {|comment| JiraClient::Comment.from_response(comment) } }
13
14
  convert :project, JiraClient::Project
14
15
  convert :worklog, JiraClient::Worklog
16
+ convert :issuetype, JiraClient::IssueType
17
+ convert :subtasks, JiraClient::Issue
18
+
19
+ alias :comments :comment
15
20
 
16
21
  class << self
17
22
 
@@ -22,5 +27,10 @@ module JiraClient
22
27
  end
23
28
 
24
29
  end
30
+
31
+ def to_s
32
+ "#{key} #{summary}"
33
+ end
34
+
25
35
  end
26
36
  end
@@ -0,0 +1,5 @@
1
+ module JiraClient
2
+ class IssueType < JiraClient::Base
3
+ attr_reader :description, :name, :subtask
4
+ end
5
+ end
@@ -1,5 +1,9 @@
1
1
  module JiraClient
2
2
  class Project < JiraClient::Base
3
3
  attr_reader :name, :key
4
+
5
+ def to_s
6
+ name
7
+ end
4
8
  end
5
9
  end
@@ -7,5 +7,9 @@ module JiraClient
7
7
 
8
8
  convert :server_time, lambda {|value| Time.parse(value)}
9
9
  convert :build_date, lambda {|value| Time.parse(value)}
10
+
11
+ def to_s
12
+ "#{base_url} (#{version})"
13
+ end
10
14
  end
11
15
  end
@@ -3,5 +3,9 @@ module JiraClient
3
3
  OPEN = 1; CLOSE = 2; START_PROGRESS = 4; REOPEN = 3; RESOLVE = 5;
4
4
 
5
5
  attr_reader :id, :name, :description
6
+
7
+ def to_s
8
+ name
9
+ end
6
10
  end
7
11
  end
@@ -6,5 +6,9 @@ module JiraClient
6
6
  @attrs[:active] == true
7
7
  end
8
8
 
9
+ def to_s
10
+ display_name
11
+ end
12
+
9
13
  end
10
14
  end
@@ -1,3 +1,3 @@
1
1
  module JiraClient
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -1,33 +1,131 @@
1
1
  {
2
2
  "expand": "renderedFields,names,schema,transitions,operations,editmeta,changelog",
3
- "id": "4321",
4
- "self": "https://example.jira.com/rest/api/2/issue/4321",
5
- "key": "PROJECT-1234",
3
+ "id": "10000",
4
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10000",
5
+ "key": "TEST-1",
6
6
  "fields": {
7
- "comment": [
8
- {
9
- "self": "http://www.example.com/jira/rest/api/2.0/issue/10010/comment/10000",
10
- "id": "10000",
11
- "author": {
12
- "self": "http://www.example.com/jira/rest/api/2.0/user?username=fred",
13
- "name": "fred",
14
- "displayName": "Fred F. User",
15
- "active": false
7
+ "comment": {
8
+ "startAt": 0,
9
+ "maxResults": 4,
10
+ "total": 4,
11
+ "comments": [
12
+ {
13
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10000/comment/10000",
14
+ "id": "10000",
15
+ "author": {
16
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
17
+ "name": "admin",
18
+ "emailAddress": "admin@example.com",
19
+ "avatarUrls": {
20
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
21
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
22
+ },
23
+ "displayName": "admin",
24
+ "active": true
25
+ },
26
+ "body": "Comment body",
27
+ "updateAuthor": {
28
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
29
+ "name": "admin",
30
+ "emailAddress": "admin@example.com",
31
+ "avatarUrls": {
32
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
33
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
34
+ },
35
+ "displayName": "admin",
36
+ "active": true
37
+ },
38
+ "created": "2013-05-13T22:37:56.134+0100",
39
+ "updated": "2013-05-13T22:37:56.134+0100"
16
40
  },
17
- "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget venenatis elit. Duis eu justo eget augue iaculis fermentum. Sed semper quam laoreet nisi egestas at posuere augue semper.",
18
- "updateAuthor": {
19
- "self": "http://www.example.com/jira/rest/api/2.0/user?username=fred",
20
- "name": "fred",
21
- "displayName": "Fred F. User",
22
- "active": false
41
+ {
42
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10000/comment/10001",
43
+ "id": "10001",
44
+ "author": {
45
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
46
+ "name": "admin",
47
+ "emailAddress": "admin@example.com",
48
+ "avatarUrls": {
49
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
50
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
51
+ },
52
+ "displayName": "admin",
53
+ "active": true
54
+ },
55
+ "body": "Didnt fix that shit",
56
+ "updateAuthor": {
57
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
58
+ "name": "admin",
59
+ "emailAddress": "admin@example.com",
60
+ "avatarUrls": {
61
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
62
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
63
+ },
64
+ "displayName": "admin",
65
+ "active": true
66
+ },
67
+ "created": "2013-05-13T22:46:00.611+0100",
68
+ "updated": "2013-05-13T22:46:00.611+0100"
23
69
  },
24
- "created": "2012-02-15T17:34:37.268-0600",
25
- "updated": "2012-02-15T17:34:37.269-0600",
26
- "visibility": {
27
- "type": "role",
28
- "value": "Administrators"
70
+ {
71
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10000/comment/10002",
72
+ "id": "10002",
73
+ "author": {
74
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
75
+ "name": "admin",
76
+ "emailAddress": "admin@example.com",
77
+ "avatarUrls": {
78
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
79
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
80
+ },
81
+ "displayName": "admin",
82
+ "active": true
83
+ },
84
+ "body": "Comment body",
85
+ "updateAuthor": {
86
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
87
+ "name": "admin",
88
+ "emailAddress": "admin@example.com",
89
+ "avatarUrls": {
90
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
91
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
92
+ },
93
+ "displayName": "admin",
94
+ "active": true
95
+ },
96
+ "created": "2013-05-13T22:46:41.508+0100",
97
+ "updated": "2013-05-13T22:46:41.508+0100"
98
+ },
99
+ {
100
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10000/comment/10003",
101
+ "id": "10003",
102
+ "author": {
103
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
104
+ "name": "admin",
105
+ "emailAddress": "admin@example.com",
106
+ "avatarUrls": {
107
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
108
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
109
+ },
110
+ "displayName": "admin",
111
+ "active": true
112
+ },
113
+ "body": "Comment body",
114
+ "updateAuthor": {
115
+ "self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
116
+ "name": "admin",
117
+ "emailAddress": "admin@example.com",
118
+ "avatarUrls": {
119
+ "16x16": "http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122",
120
+ "48x48": "http://localhost:2990/jira/secure/useravatar?avatarId=10122"
121
+ },
122
+ "displayName": "admin",
123
+ "active": true
124
+ },
125
+ "created": "2013-05-13T22:49:11.301+0100",
126
+ "updated": "2013-05-13T22:49:11.301+0100"
29
127
  }
30
- }
31
- ]
128
+ ]
129
+ }
32
130
  }
33
131
  }
@@ -0,0 +1,16 @@
1
+ {
2
+ "expand": "renderedFields,names,schema,transitions,operations,editmeta,changelog",
3
+ "id": "10000",
4
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10000",
5
+ "key": "TEST-1",
6
+ "fields": {
7
+ "issuetype": {
8
+ "self": "http://localhost:2990/jira/rest/api/2/issuetype/1",
9
+ "id": "1",
10
+ "description": "A problem which impairs or prevents the functions of the product.",
11
+ "iconUrl": "http://localhost:2990/jira/images/icons/bug.gif",
12
+ "name": "Bug",
13
+ "subtask": false
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,68 @@
1
+ {
2
+ "expand": "renderedFields,names,schema,transitions,operations,editmeta,changelog",
3
+ "id": "10000",
4
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10000",
5
+ "key": "TEST-1",
6
+ "fields": {
7
+ "subtasks": [
8
+ {
9
+ "id": "10001",
10
+ "key": "TEST-2",
11
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10001",
12
+ "fields": {
13
+ "summary": "This is a subtask",
14
+ "status": {
15
+ "self": "http://localhost:2990/jira/rest/api/2/status/1",
16
+ "description": "The issue is open and ready for the assignee to start work on it.",
17
+ "iconUrl": "http://localhost:2990/jira/images/icons/status_open.gif",
18
+ "name": "Open",
19
+ "id": "1"
20
+ },
21
+ "issuetype": {
22
+ "self": "http://localhost:2990/jira/rest/api/2/issuetype/5",
23
+ "id": "5",
24
+ "description": "The sub-task of the issue",
25
+ "iconUrl": "http://localhost:2990/jira/images/icons/issue_subtask.gif",
26
+ "name": "Sub-task",
27
+ "subtask": true
28
+ },
29
+ "priority": {
30
+ "self": "http://localhost:2990/jira/rest/api/2/priority/3",
31
+ "iconUrl": "http://localhost:2990/jira/images/icons/priority_major.gif",
32
+ "name": "Major",
33
+ "id": "3"
34
+ }
35
+ }
36
+ },
37
+ {
38
+ "id": "10002",
39
+ "key": "TEST-3",
40
+ "self": "http://localhost:2990/jira/rest/api/2/issue/10002",
41
+ "fields": {
42
+ "summary": "This is a subtask",
43
+ "status": {
44
+ "self": "http://localhost:2990/jira/rest/api/2/status/1",
45
+ "description": "The issue is open and ready for the assignee to start work on it.",
46
+ "iconUrl": "http://localhost:2990/jira/images/icons/status_open.gif",
47
+ "name": "Open",
48
+ "id": "1"
49
+ },
50
+ "issuetype": {
51
+ "self": "http://localhost:2990/jira/rest/api/2/issuetype/5",
52
+ "id": "5",
53
+ "description": "The sub-task of the issue",
54
+ "iconUrl": "http://localhost:2990/jira/images/icons/issue_subtask.gif",
55
+ "name": "Sub-task",
56
+ "subtask": true
57
+ },
58
+ "priority": {
59
+ "self": "http://localhost:2990/jira/rest/api/2/priority/3",
60
+ "iconUrl": "http://localhost:2990/jira/images/icons/priority_major.gif",
61
+ "name": "Major",
62
+ "id": "3"
63
+ }
64
+ }
65
+ }
66
+ ]
67
+ }
68
+ }
@@ -56,6 +56,45 @@ describe JiraClient::API::Issues do
56
56
  expect(@issue.status).to be_a_kind_of JiraClient::Status
57
57
  end
58
58
  end
59
+ context "with an issuetype" do
60
+
61
+ before do
62
+ stub_get("/issue/PROJECT-1234").with(:query => {:fields => "issuetype"}).to_return(:body => fixture("issue_with_issuetype.json"))
63
+ @issue = JiraClient.find_issue_by_key("PROJECT-1234", :fields => [:issuetype])
64
+ end
65
+
66
+ it "requests the correct resource" do
67
+ expect(a_get("/issue/PROJECT-1234?fields=issuetype")).to have_been_made
68
+ end
69
+ it "sets the correct values" do
70
+ type = @issue.issuetype
71
+ expect(type).to be_a_kind_of JiraClient::IssueType
72
+ type.name.should == "Bug"
73
+ type.description.should == "A problem which impairs or prevents the functions of the product."
74
+ end
75
+
76
+ end
77
+ context "with subtasks" do
78
+
79
+ before do
80
+ stub_get("/issue/PROJECT-1234").with(:query => {:fields => "subtasks"}).to_return(:body => fixture("issue_with_subtasks.json"))
81
+ @issue = JiraClient.find_issue_by_key("PROJECT-1234", :fields => [:subtasks])
82
+ end
83
+
84
+ it "requests the correct resource" do
85
+ expect(a_get("/issue/PROJECT-1234?fields=subtasks")).to have_been_made
86
+ end
87
+ it "sets the correct values" do
88
+ subtasks = @issue.subtasks
89
+ expect(subtasks).to be_a_kind_of Array
90
+ subtasks.each do |subtask|
91
+ expect(subtask).to be_a_kind_of JiraClient::Issue
92
+ subtask.summary.should == "This is a subtask"
93
+ subtask.issuetype.name.should == "Sub-task"
94
+ end
95
+ end
96
+
97
+ end
59
98
  context "with timetracking" do
60
99
 
61
100
  before do
@@ -104,6 +143,9 @@ describe JiraClient::API::Issues do
104
143
  comment.should be_a_kind_of JiraClient::Comment
105
144
  end
106
145
  end
146
+ it "aliases comments" do
147
+ @issue.comments.should == @issue.comment
148
+ end
107
149
  end
108
150
  end
109
151
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jira_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-13 00:00:00.000000000 Z
12
+ date: 2013-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -124,6 +124,7 @@ files:
124
124
  - lib/jira_client/error/resource_not_found.rb
125
125
  - lib/jira_client/error/unauthorized.rb
126
126
  - lib/jira_client/issue.rb
127
+ - lib/jira_client/issue_type.rb
127
128
  - lib/jira_client/project.rb
128
129
  - lib/jira_client/server_info.rb
129
130
  - lib/jira_client/status.rb
@@ -140,7 +141,9 @@ files:
140
141
  - spec/fixtures/invalid_jql.json
141
142
  - spec/fixtures/issue_with_comments.json
142
143
  - spec/fixtures/issue_with_description.json
144
+ - spec/fixtures/issue_with_issuetype.json
143
145
  - spec/fixtures/issue_with_status.json
146
+ - spec/fixtures/issue_with_subtasks.json
144
147
  - spec/fixtures/issue_with_timetracking.json
145
148
  - spec/fixtures/issue_with_worklogs.json
146
149
  - spec/fixtures/issues.json
@@ -199,7 +202,9 @@ test_files:
199
202
  - spec/fixtures/invalid_jql.json
200
203
  - spec/fixtures/issue_with_comments.json
201
204
  - spec/fixtures/issue_with_description.json
205
+ - spec/fixtures/issue_with_issuetype.json
202
206
  - spec/fixtures/issue_with_status.json
207
+ - spec/fixtures/issue_with_subtasks.json
203
208
  - spec/fixtures/issue_with_timetracking.json
204
209
  - spec/fixtures/issue_with_worklogs.json
205
210
  - spec/fixtures/issues.json