jira-ruby 1.8.0 → 2.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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +1 -1
- data/README.md +3 -3
- data/example.rb +8 -0
- data/lib/jira/base.rb +1 -1
- data/lib/jira/client.rb +71 -6
- data/lib/jira/http_client.rb +23 -9
- data/lib/jira/http_error.rb +1 -1
- data/lib/jira/jwt_client.rb +10 -9
- data/lib/jira/oauth_client.rb +17 -5
- data/lib/jira/request_client.rb +15 -3
- data/lib/jira/resource/attachment.rb +19 -14
- data/lib/jira/resource/issue_picker_suggestions.rb +24 -0
- data/lib/jira/resource/issue_picker_suggestions_issue.rb +10 -0
- data/lib/jira/resource/sprint.rb +12 -8
- data/lib/jira/resource/suggested_issue.rb +9 -0
- data/lib/jira/resource/user.rb +1 -1
- data/lib/jira/resource/watcher.rb +7 -0
- data/lib/jira/version.rb +1 -1
- data/lib/jira-ruby.rb +4 -0
- data/spec/integration/user_spec.rb +3 -3
- data/spec/integration/watcher_spec.rb +15 -6
- data/spec/jira/base_spec.rb +12 -0
- data/spec/jira/client_spec.rb +22 -0
- data/spec/jira/http_client_spec.rb +35 -2
- data/spec/jira/oauth_client_spec.rb +27 -10
- data/spec/jira/request_client_spec.rb +37 -10
- data/spec/jira/resource/attachment_spec.rb +79 -22
- data/spec/jira/resource/issue_picker_suggestions_spec.rb +79 -0
- data/spec/jira/resource/jira_picker_suggestions_issue_spec.rb +18 -0
- data/spec/jira/resource/sprint_spec.rb +23 -11
- metadata +38 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95a9c55b6f750bc29bdb34f6af24b252bbbf04317ca31ed9e76753a4c257f465
|
4
|
+
data.tar.gz: 56e109f946831308a8a7b30c699ebd5b6b5805c5724e3ec47ba3ac252d2df0f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba00e2efe10f65d2804c2c556774abab8c94d1fa746ca6c681cc7a967809bbb6309000b183049cdb9f8117dc2c8f0f60e22cbd77e6973736c7ca621989977509
|
7
|
+
data.tar.gz: bcfad2a8bcc354211e860ef7912eaedd202f189ccbedb03679032468d85425cc134d9e69dc1f4f8f4b0b238fa761cddbe21683e256379aafe29a1ca4d9d8a743
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -163,7 +163,7 @@ api_token = "myApiToken"
|
|
163
163
|
options = {
|
164
164
|
:username => username,
|
165
165
|
:password => api_token,
|
166
|
-
:site => 'http://localhost:8080/', # or 'https://<your_subdomain>.atlassian.net'
|
166
|
+
:site => 'http://localhost:8080/', # or 'https://<your_subdomain>.atlassian.net/'
|
167
167
|
:context_path => '/myjira', # often blank
|
168
168
|
:auth_type => :basic,
|
169
169
|
:read_timeout => 120
|
@@ -307,7 +307,7 @@ class App < Sinatra::Base
|
|
307
307
|
# site uri, and the request token, access token, and authorize paths
|
308
308
|
before do
|
309
309
|
options = {
|
310
|
-
:site => 'http://localhost:2990',
|
310
|
+
:site => 'http://localhost:2990/',
|
311
311
|
:context_path => '/jira',
|
312
312
|
:signature_method => 'RSA-SHA1',
|
313
313
|
:request_token_path => "/plugins/servlet/oauth/request-token",
|
@@ -405,7 +405,7 @@ require 'pp'
|
|
405
405
|
require 'jira-ruby'
|
406
406
|
|
407
407
|
options = {
|
408
|
-
:site => 'http://localhost:2990',
|
408
|
+
:site => 'http://localhost:2990/',
|
409
409
|
:context_path => '/jira',
|
410
410
|
:signature_method => 'RSA-SHA1',
|
411
411
|
:private_key_file => "rsakey.pem",
|
data/example.rb
CHANGED
@@ -166,6 +166,14 @@ client.Issue.jql(a_normal_jql_search, max_results: 500)
|
|
166
166
|
# # --------------------------
|
167
167
|
# issue.comments.first.save({"body" => "an updated comment frome example.rb"})
|
168
168
|
|
169
|
+
|
170
|
+
# # Add attachment to Issue
|
171
|
+
# # ------------------------
|
172
|
+
# issue = client.Issue.find('PROJ-1')
|
173
|
+
# attachment = issue.attachments.build
|
174
|
+
# attachment.save('file': '/path/to/file')
|
175
|
+
#
|
176
|
+
|
169
177
|
# List all available link types
|
170
178
|
# ------------------------------
|
171
179
|
pp client.Issuelinktype.all
|
data/lib/jira/base.rb
CHANGED
@@ -424,7 +424,7 @@ module JIRA
|
|
424
424
|
end
|
425
425
|
if @attrs['self']
|
426
426
|
the_url = @attrs['self']
|
427
|
-
the_url = the_url.sub(@client.options[:site], '') if @client.options[:site]
|
427
|
+
the_url = the_url.sub(@client.options[:site].chomp('/'), '') if @client.options[:site]
|
428
428
|
the_url
|
429
429
|
elsif key_value
|
430
430
|
self.class.singular_path(client, key_value.to_s, prefix)
|
data/lib/jira/client.rb
CHANGED
@@ -6,7 +6,7 @@ module JIRA
|
|
6
6
|
# This class is the main access point for all JIRA::Resource instances.
|
7
7
|
#
|
8
8
|
# The client must be initialized with an options hash containing
|
9
|
-
# configuration options.
|
9
|
+
# configuration options. The available options are:
|
10
10
|
#
|
11
11
|
# :site => 'http://localhost:2990',
|
12
12
|
# :context_path => '/jira',
|
@@ -14,6 +14,7 @@ module JIRA
|
|
14
14
|
# :request_token_path => "/plugins/servlet/oauth/request-token",
|
15
15
|
# :authorize_path => "/plugins/servlet/oauth/authorize",
|
16
16
|
# :access_token_path => "/plugins/servlet/oauth/access-token",
|
17
|
+
# :private_key => nil,
|
17
18
|
# :private_key_file => "rsakey.pem",
|
18
19
|
# :rest_base_path => "/rest/api/2",
|
19
20
|
# :consumer_key => nil,
|
@@ -28,8 +29,17 @@ module JIRA
|
|
28
29
|
# :proxy_port => nil,
|
29
30
|
# :proxy_username => nil,
|
30
31
|
# :proxy_password => nil,
|
32
|
+
# :use_cookies => nil,
|
31
33
|
# :additional_cookies => nil,
|
32
|
-
# :default_headers => {}
|
34
|
+
# :default_headers => {},
|
35
|
+
# :use_client_cert => false,
|
36
|
+
# :read_timeout => nil,
|
37
|
+
# :http_debug => false,
|
38
|
+
# :shared_secret => nil,
|
39
|
+
# :cert_path => nil,
|
40
|
+
# :key_path => nil,
|
41
|
+
# :ssl_client_cert => nil,
|
42
|
+
# :ssl_client_key => nil
|
33
43
|
#
|
34
44
|
# See the JIRA::Base class methods for all of the available methods on these accessor
|
35
45
|
# objects.
|
@@ -48,6 +58,43 @@ module JIRA
|
|
48
58
|
|
49
59
|
def_delegators :@request_client, :init_access_token, :set_access_token, :set_request_token, :request_token, :access_token, :authenticated?
|
50
60
|
|
61
|
+
DEFINED_OPTIONS = [
|
62
|
+
:site,
|
63
|
+
:context_path,
|
64
|
+
:signature_method,
|
65
|
+
:request_token_path,
|
66
|
+
:authorize_path,
|
67
|
+
:access_token_path,
|
68
|
+
:private_key,
|
69
|
+
:private_key_file,
|
70
|
+
:rest_base_path,
|
71
|
+
:consumer_key,
|
72
|
+
:consumer_secret,
|
73
|
+
:ssl_verify_mode,
|
74
|
+
:ssl_version,
|
75
|
+
:use_ssl,
|
76
|
+
:username,
|
77
|
+
:password,
|
78
|
+
:auth_type,
|
79
|
+
:proxy_address,
|
80
|
+
:proxy_port,
|
81
|
+
:proxy_username,
|
82
|
+
:proxy_password,
|
83
|
+
:use_cookies,
|
84
|
+
:additional_cookies,
|
85
|
+
:default_headers,
|
86
|
+
:use_client_cert,
|
87
|
+
:read_timeout,
|
88
|
+
:http_debug,
|
89
|
+
:issuer,
|
90
|
+
:base_url,
|
91
|
+
:shared_secret,
|
92
|
+
:cert_path,
|
93
|
+
:key_path,
|
94
|
+
:ssl_client_cert,
|
95
|
+
:ssl_client_key
|
96
|
+
].freeze
|
97
|
+
|
51
98
|
DEFAULT_OPTIONS = {
|
52
99
|
site: 'http://localhost:2990',
|
53
100
|
context_path: '/jira',
|
@@ -65,11 +112,15 @@ module JIRA
|
|
65
112
|
@options = options
|
66
113
|
@options[:rest_base_path] = @options[:context_path] + @options[:rest_base_path]
|
67
114
|
|
115
|
+
unknown_options = options.keys.reject { |o| DEFINED_OPTIONS.include?(o) }
|
116
|
+
raise ArgumentError, "Unknown option(s) given: #{unknown_options}" unless unknown_options.empty?
|
117
|
+
|
68
118
|
if options[:use_client_cert]
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
119
|
+
@options[:ssl_client_cert] = OpenSSL::X509::Certificate.new(File.read(@options[:cert_path])) if @options[:cert_path]
|
120
|
+
@options[:ssl_client_key] = OpenSSL::PKey::RSA.new(File.read(@options[:key_path])) if @options[:key_path]
|
121
|
+
|
122
|
+
raise ArgumentError, 'Options: :cert_path or :ssl_client_cert must be set when :use_client_cert is true' unless @options[:ssl_client_cert]
|
123
|
+
raise ArgumentError, 'Options: :key_path or :ssl_client_key must be set when :use_client_cert is true' unless @options[:ssl_client_key]
|
73
124
|
end
|
74
125
|
|
75
126
|
case options[:auth_type]
|
@@ -206,6 +257,10 @@ module JIRA
|
|
206
257
|
JIRA::Resource::IssuelinktypeFactory.new(self)
|
207
258
|
end
|
208
259
|
|
260
|
+
def IssuePickerSuggestions
|
261
|
+
JIRA::Resource::IssuePickerSuggestionsFactory.new(self)
|
262
|
+
end
|
263
|
+
|
209
264
|
def Remotelink
|
210
265
|
JIRA::Resource::RemotelinkFactory.new(self)
|
211
266
|
end
|
@@ -233,6 +288,11 @@ module JIRA
|
|
233
288
|
request(:post, path, body, merge_default_headers(headers))
|
234
289
|
end
|
235
290
|
|
291
|
+
def post_multipart(path, file, headers = {})
|
292
|
+
puts "post multipart: #{path} - [#{file}]" if @http_debug
|
293
|
+
@request_client.request_multipart(path, file, headers)
|
294
|
+
end
|
295
|
+
|
236
296
|
def put(path, body = '', headers = {})
|
237
297
|
headers = { 'Content-Type' => 'application/json' }.merge(headers)
|
238
298
|
request(:put, path, body, merge_default_headers(headers))
|
@@ -245,6 +305,11 @@ module JIRA
|
|
245
305
|
@request_client.request(http_method, path, body, headers)
|
246
306
|
end
|
247
307
|
|
308
|
+
# Stops sensitive client information from being displayed in logs
|
309
|
+
def inspect
|
310
|
+
"#<JIRA::Client:#{object_id}>"
|
311
|
+
end
|
312
|
+
|
248
313
|
protected
|
249
314
|
|
250
315
|
def merge_default_headers(headers)
|
data/lib/jira/http_client.rb
CHANGED
@@ -29,12 +29,15 @@ module JIRA
|
|
29
29
|
path = request_path(url)
|
30
30
|
request = Net::HTTP.const_get(http_method.to_s.capitalize).new(path, headers)
|
31
31
|
request.body = body unless body.nil?
|
32
|
-
|
33
|
-
request
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
|
33
|
+
execute_request(request)
|
34
|
+
end
|
35
|
+
|
36
|
+
def make_multipart_request(url, body, headers = {})
|
37
|
+
path = request_path(url)
|
38
|
+
request = Net::HTTP::Post::Multipart.new(path, body, headers)
|
39
|
+
|
40
|
+
execute_request(request)
|
38
41
|
end
|
39
42
|
|
40
43
|
def basic_auth_http_conn
|
@@ -50,8 +53,8 @@ module JIRA
|
|
50
53
|
http_conn = http_class.new(uri.host, uri.port)
|
51
54
|
http_conn.use_ssl = @options[:use_ssl]
|
52
55
|
if @options[:use_client_cert]
|
53
|
-
http_conn.cert = @options[:
|
54
|
-
http_conn.key = @options[:
|
56
|
+
http_conn.cert = @options[:ssl_client_cert]
|
57
|
+
http_conn.key = @options[:ssl_client_key]
|
55
58
|
end
|
56
59
|
http_conn.verify_mode = @options[:ssl_verify_mode]
|
57
60
|
http_conn.ssl_version = @options[:ssl_version] if @options[:ssl_version]
|
@@ -60,7 +63,7 @@ module JIRA
|
|
60
63
|
end
|
61
64
|
|
62
65
|
def uri
|
63
|
-
|
66
|
+
URI.parse(@options[:site])
|
64
67
|
end
|
65
68
|
|
66
69
|
def authenticated?
|
@@ -69,6 +72,17 @@ module JIRA
|
|
69
72
|
|
70
73
|
private
|
71
74
|
|
75
|
+
def execute_request(request)
|
76
|
+
add_cookies(request) if options[:use_cookies]
|
77
|
+
request.basic_auth(@options[:username], @options[:password]) if @options[:username] && @options[:password]
|
78
|
+
|
79
|
+
response = basic_auth_http_conn.request(request)
|
80
|
+
@authenticated = response.is_a? Net::HTTPOK
|
81
|
+
store_cookies(response) if options[:use_cookies]
|
82
|
+
|
83
|
+
response
|
84
|
+
end
|
85
|
+
|
72
86
|
def request_path(url)
|
73
87
|
parsed_uri = URI(url)
|
74
88
|
|
data/lib/jira/http_error.rb
CHANGED
data/lib/jira/jwt_client.rb
CHANGED
@@ -3,16 +3,15 @@ require 'atlassian/jwt'
|
|
3
3
|
module JIRA
|
4
4
|
class JwtClient < HttpClient
|
5
5
|
def make_request(http_method, url, body = '', headers = {})
|
6
|
-
|
7
|
-
path = request_path(http_method, url)
|
6
|
+
@http_method = http_method
|
8
7
|
|
9
|
-
|
10
|
-
|
8
|
+
super(http_method, url, body, headers)
|
9
|
+
end
|
10
|
+
|
11
|
+
def make_multipart_request(url, data, headers = {})
|
12
|
+
@http_method = :post
|
11
13
|
|
12
|
-
|
13
|
-
@authenticated = response.is_a? Net::HTTPOK
|
14
|
-
store_cookies(response) if options[:use_cookies]
|
15
|
-
response
|
14
|
+
super(url, data, headers)
|
16
15
|
end
|
17
16
|
|
18
17
|
class JwtUriBuilder
|
@@ -53,7 +52,9 @@ module JIRA
|
|
53
52
|
|
54
53
|
private
|
55
54
|
|
56
|
-
|
55
|
+
attr_reader :http_method
|
56
|
+
|
57
|
+
def request_path(url)
|
57
58
|
JwtUriBuilder.new(
|
58
59
|
url,
|
59
60
|
http_method.to_s,
|
data/lib/jira/oauth_client.rb
CHANGED
@@ -38,6 +38,8 @@ module JIRA
|
|
38
38
|
@options[:request_token_path] = @options[:context_path] + @options[:request_token_path]
|
39
39
|
@options[:authorize_path] = @options[:context_path] + @options[:authorize_path]
|
40
40
|
@options[:access_token_path] = @options[:context_path] + @options[:access_token_path]
|
41
|
+
# proxy_address does not exist in oauth's gem context but proxy does
|
42
|
+
@options[:proxy] = @options[:proxy_address] if @options[:proxy_address]
|
41
43
|
OAuth::Consumer.new(@options[:consumer_key], @options[:consumer_secret], @options)
|
42
44
|
end
|
43
45
|
|
@@ -72,29 +74,39 @@ module JIRA
|
|
72
74
|
@access_token
|
73
75
|
end
|
74
76
|
|
75
|
-
def make_request(http_method,
|
77
|
+
def make_request(http_method, url, body = '', headers = {})
|
76
78
|
# When using oauth_2legged we need to add an empty oauth_token parameter to every request.
|
77
79
|
if @options[:auth_type] == :oauth_2legged
|
78
80
|
oauth_params_str = 'oauth_token='
|
79
|
-
uri = URI.parse(
|
81
|
+
uri = URI.parse(url)
|
80
82
|
uri.query = if uri.query.to_s == ''
|
81
83
|
oauth_params_str
|
82
84
|
else
|
83
85
|
uri.query + '&' + oauth_params_str
|
84
86
|
end
|
85
|
-
|
87
|
+
url = uri.to_s
|
86
88
|
end
|
87
89
|
|
88
90
|
case http_method
|
89
91
|
when :delete, :get, :head
|
90
|
-
response = access_token.send http_method,
|
92
|
+
response = access_token.send http_method, url, headers
|
91
93
|
when :post, :put
|
92
|
-
response = access_token.send http_method,
|
94
|
+
response = access_token.send http_method, url, body, headers
|
93
95
|
end
|
94
96
|
@authenticated = true
|
95
97
|
response
|
96
98
|
end
|
97
99
|
|
100
|
+
def make_multipart_request(url, data, headers = {})
|
101
|
+
request = Net::HTTP::Post::Multipart.new url, data, headers
|
102
|
+
|
103
|
+
access_token.sign! request
|
104
|
+
|
105
|
+
response = consumer.http.request(request)
|
106
|
+
@authenticated = true
|
107
|
+
response
|
108
|
+
end
|
109
|
+
|
98
110
|
def authenticated?
|
99
111
|
@authenticated
|
100
112
|
end
|
data/lib/jira/request_client.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'oauth'
|
2
2
|
require 'json'
|
3
3
|
require 'net/https'
|
4
|
-
# require 'pry'
|
5
4
|
|
6
5
|
module JIRA
|
7
6
|
class RequestClient
|
@@ -11,9 +10,22 @@ module JIRA
|
|
11
10
|
|
12
11
|
def request(*args)
|
13
12
|
response = make_request(*args)
|
14
|
-
# binding.pry unless response.kind_of?(Net::HTTPSuccess)
|
15
13
|
raise HTTPError, response unless response.is_a?(Net::HTTPSuccess)
|
16
14
|
response
|
17
15
|
end
|
16
|
+
|
17
|
+
def request_multipart(*args)
|
18
|
+
response = make_multipart_request(*args)
|
19
|
+
raise HTTPError, response unless response.is_a?(Net::HTTPSuccess)
|
20
|
+
response
|
21
|
+
end
|
22
|
+
|
23
|
+
def make_request(*args)
|
24
|
+
raise NotImplementedError
|
25
|
+
end
|
26
|
+
|
27
|
+
def make_multipart_request(*args)
|
28
|
+
raise NotImplementedError
|
29
|
+
end
|
18
30
|
end
|
19
|
-
end
|
31
|
+
end
|
@@ -19,27 +19,32 @@ module JIRA
|
|
19
19
|
parse_json(response.body)
|
20
20
|
end
|
21
21
|
|
22
|
-
def save!(attrs)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
request = Net::HTTP::Post::Multipart.new url, data, headers
|
27
|
-
request.basic_auth(client.request_client.options[:username],
|
28
|
-
client.request_client.options[:password])
|
22
|
+
def save!(attrs, path = url)
|
23
|
+
file = attrs['file'] || attrs[:file] # Keep supporting 'file' parameter as a string for backward compatibility
|
24
|
+
mime_type = attrs[:mimeType] || 'application/binary'
|
29
25
|
|
30
|
-
|
26
|
+
headers = { 'X-Atlassian-Token' => 'nocheck' }
|
27
|
+
data = { 'file' => UploadIO.new(file, mime_type, file) }
|
31
28
|
|
32
|
-
|
33
|
-
unless response.body.nil? || response.body.length < 2
|
34
|
-
json = self.class.parse_json(response.body)
|
35
|
-
attachment = json[0]
|
29
|
+
response = client.post_multipart(path, data , headers)
|
36
30
|
|
37
|
-
|
38
|
-
end
|
31
|
+
set_attributes(attrs, response)
|
39
32
|
|
40
33
|
@expanded = false
|
41
34
|
true
|
42
35
|
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def set_attributes(attributes, response)
|
40
|
+
set_attrs(attributes, false)
|
41
|
+
return if response.body.nil? || response.body.length < 2
|
42
|
+
|
43
|
+
json = self.class.parse_json(response.body)
|
44
|
+
attachment = json[0]
|
45
|
+
|
46
|
+
set_attrs(attachment)
|
47
|
+
end
|
43
48
|
end
|
44
49
|
end
|
45
50
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module JIRA
|
2
|
+
module Resource
|
3
|
+
class IssuePickerSuggestionsFactory < JIRA::BaseFactory # :nodoc:
|
4
|
+
end
|
5
|
+
|
6
|
+
class IssuePickerSuggestions < JIRA::Base
|
7
|
+
has_many :sections, class: JIRA::Resource::IssuePickerSuggestionsIssue
|
8
|
+
|
9
|
+
def self.all(client, query = '', options = { current_jql: nil, current_issue_key: nil, current_project_id: nil, show_sub_tasks: nil, show_sub_tasks_parent: nil })
|
10
|
+
url = client.options[:rest_base_path] + "/issue/picker?query=#{CGI.escape(query)}"
|
11
|
+
|
12
|
+
url << "¤tJQL=#{CGI.escape(options[:current_jql])}" if options[:current_jql]
|
13
|
+
url << "¤tIssueKey=#{CGI.escape(options[:current_issue_key])}" if options[:current_issue_key]
|
14
|
+
url << "¤tProjectId=#{CGI.escape(options[:current_project_id])}" if options[:current_project_id]
|
15
|
+
url << "&showSubTasks=#{options[:show_sub_tasks]}" if options[:show_sub_tasks]
|
16
|
+
url << "&showSubTaskParent=#{options[:show_sub_task_parent]}" if options[:show_sub_task_parent]
|
17
|
+
|
18
|
+
response = client.get(url)
|
19
|
+
json = parse_json(response.body)
|
20
|
+
client.IssuePickerSuggestions.build(json)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/jira/resource/sprint.rb
CHANGED
@@ -5,7 +5,7 @@ module JIRA
|
|
5
5
|
|
6
6
|
class Sprint < JIRA::Base
|
7
7
|
def self.find(client, key)
|
8
|
-
response = client.get(
|
8
|
+
response = client.get(agile_path(client, key))
|
9
9
|
json = parse_json(response.body)
|
10
10
|
client.Sprint.build(json)
|
11
11
|
end
|
@@ -19,7 +19,7 @@ module JIRA
|
|
19
19
|
|
20
20
|
def add_issue(issue)
|
21
21
|
request_body = { issues: [issue.id] }.to_json
|
22
|
-
response = client.post(
|
22
|
+
response = client.post("#{agile_path}/issue", request_body)
|
23
23
|
true
|
24
24
|
end
|
25
25
|
|
@@ -47,8 +47,8 @@ module JIRA
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def get_sprint_details
|
50
|
-
search_url =
|
51
|
-
|
50
|
+
search_url =
|
51
|
+
"#{client.options[:site]}#{client.options[:client_path]}/rest/greenhopper/1.0/rapid/charts/sprintreport?rapidViewId=#{rapidview_id}&sprintId=#{id}"
|
52
52
|
begin
|
53
53
|
response = client.get(search_url)
|
54
54
|
rescue StandardError
|
@@ -76,12 +76,12 @@ module JIRA
|
|
76
76
|
|
77
77
|
def save(attrs = {}, _path = nil)
|
78
78
|
attrs = @attrs if attrs.empty?
|
79
|
-
super(attrs,
|
79
|
+
super(attrs, agile_path)
|
80
80
|
end
|
81
81
|
|
82
82
|
def save!(attrs = {}, _path = nil)
|
83
83
|
attrs = @attrs if attrs.empty?
|
84
|
-
super(attrs,
|
84
|
+
super(attrs, agile_path)
|
85
85
|
end
|
86
86
|
|
87
87
|
# WORK IN PROGRESS
|
@@ -93,8 +93,12 @@ module JIRA
|
|
93
93
|
|
94
94
|
private
|
95
95
|
|
96
|
-
def
|
97
|
-
|
96
|
+
def agile_path
|
97
|
+
self.class.agile_path(client, id)
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.agile_path(client, key)
|
101
|
+
"#{client.options[:context_path]}/rest/agile/1.0/sprint/#{key}"
|
98
102
|
end
|
99
103
|
end
|
100
104
|
end
|
data/lib/jira/resource/user.rb
CHANGED
@@ -18,7 +18,7 @@ module JIRA
|
|
18
18
|
|
19
19
|
# Cannot retrieve more than 1,000 users through the api, please see: https://jira.atlassian.com/browse/JRASERVER-65089
|
20
20
|
def self.all(client)
|
21
|
-
response = client.get("/rest/api/2/
|
21
|
+
response = client.get("/rest/api/2/users/search?username=_&maxResults=#{MAX_RESULTS}")
|
22
22
|
all_users = JSON.parse(response.body)
|
23
23
|
|
24
24
|
all_users.flatten.uniq.map do |user|
|
data/lib/jira/version.rb
CHANGED
data/lib/jira-ruby.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
$LOAD_PATH << __dir__
|
2
2
|
|
3
|
+
require 'active_support'
|
3
4
|
require 'active_support/inflector'
|
4
5
|
ActiveSupport::Inflector.inflections do |inflector|
|
5
6
|
inflector.singular /status$/, 'status'
|
@@ -25,6 +26,9 @@ require 'jira/resource/worklog'
|
|
25
26
|
require 'jira/resource/applinks'
|
26
27
|
require 'jira/resource/issuelinktype'
|
27
28
|
require 'jira/resource/issuelink'
|
29
|
+
require 'jira/resource/suggested_issue'
|
30
|
+
require 'jira/resource/issue_picker_suggestions_issue'
|
31
|
+
require 'jira/resource/issue_picker_suggestions'
|
28
32
|
require 'jira/resource/remotelink'
|
29
33
|
require 'jira/resource/sprint'
|
30
34
|
require 'jira/resource/sprint_report'
|
@@ -21,18 +21,18 @@ describe JIRA::Resource::User do
|
|
21
21
|
describe '#all' do
|
22
22
|
let(:client) do
|
23
23
|
client = double(options: { rest_base_path: '/jira/rest/api/2' })
|
24
|
-
allow(client).to receive(:get).with('/rest/api/2/
|
24
|
+
allow(client).to receive(:get).with('/rest/api/2/users/search?username=_&maxResults=1000').and_return(JIRA::Resource::UserFactory.new(client))
|
25
25
|
client
|
26
26
|
end
|
27
27
|
|
28
28
|
before do
|
29
29
|
allow(client).to receive(:get)
|
30
|
-
.with('/rest/api/2/
|
30
|
+
.with('/rest/api/2/users/search?username=_&maxResults=1000') { OpenStruct.new(body: '["User1"]') }
|
31
31
|
allow(client).to receive_message_chain(:User, :build).with('users') { [] }
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'gets users with maxResults of 1000' do
|
35
|
-
expect(client).to receive(:get).with('/rest/api/2/
|
35
|
+
expect(client).to receive(:get).with('/rest/api/2/users/search?username=_&maxResults=1000')
|
36
36
|
expect(client).to receive_message_chain(:User, :build).with('User1')
|
37
37
|
JIRA::Resource::User.all(client)
|
38
38
|
end
|