jira-ruby 1.8.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/jira/client.rb +5 -0
- data/lib/jira/http_client.rb +21 -7
- data/lib/jira/http_error.rb +1 -1
- data/lib/jira/jwt_client.rb +10 -9
- data/lib/jira/oauth_client.rb +15 -5
- data/lib/jira/request_client.rb +15 -3
- data/lib/jira/resource/attachment.rb +19 -14
- data/lib/jira/resource/watcher.rb +7 -0
- data/lib/jira/version.rb +1 -1
- data/spec/integration/watcher_spec.rb +15 -6
- data/spec/jira/http_client_spec.rb +33 -0
- 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
- metadata +28 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5226fc516e3462a036601589022516b7b81d341e
|
4
|
+
data.tar.gz: 3383609edaa34f0c8b78ac7002e21d051a02fbea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d94d3e49e1bdb3abe978049db45eb5a1ed4698822900b3df3fe3f6660cdfb739968af5366f2f359006a39af6fbddc926bd670126ce9daf3de0ef95d138d7ffb3
|
7
|
+
data.tar.gz: 9b53adb2af3746bd00703afc0afa33aa825003261b4afa1328a99ba54183bfb43e865a568c7dbfb8d2b38fd6c8ae5f75f05bf8bf6f59e4bf1fc864378e370ab7
|
data/lib/jira/client.rb
CHANGED
@@ -233,6 +233,11 @@ module JIRA
|
|
233
233
|
request(:post, path, body, merge_default_headers(headers))
|
234
234
|
end
|
235
235
|
|
236
|
+
def post_multipart(path, file, headers = {})
|
237
|
+
puts "post multipart: #{path} - [#{file}]" if @http_debug
|
238
|
+
@request_client.request_multipart(path, file, headers)
|
239
|
+
end
|
240
|
+
|
236
241
|
def put(path, body = '', headers = {})
|
237
242
|
headers = { 'Content-Type' => 'application/json' }.merge(headers)
|
238
243
|
request(:put, path, body, 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
|
@@ -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
@@ -72,29 +72,39 @@ module JIRA
|
|
72
72
|
@access_token
|
73
73
|
end
|
74
74
|
|
75
|
-
def make_request(http_method,
|
75
|
+
def make_request(http_method, url, body = '', headers = {})
|
76
76
|
# When using oauth_2legged we need to add an empty oauth_token parameter to every request.
|
77
77
|
if @options[:auth_type] == :oauth_2legged
|
78
78
|
oauth_params_str = 'oauth_token='
|
79
|
-
uri = URI.parse(
|
79
|
+
uri = URI.parse(url)
|
80
80
|
uri.query = if uri.query.to_s == ''
|
81
81
|
oauth_params_str
|
82
82
|
else
|
83
83
|
uri.query + '&' + oauth_params_str
|
84
84
|
end
|
85
|
-
|
85
|
+
url = uri.to_s
|
86
86
|
end
|
87
87
|
|
88
88
|
case http_method
|
89
89
|
when :delete, :get, :head
|
90
|
-
response = access_token.send http_method,
|
90
|
+
response = access_token.send http_method, url, headers
|
91
91
|
when :post, :put
|
92
|
-
response = access_token.send http_method,
|
92
|
+
response = access_token.send http_method, url, body, headers
|
93
93
|
end
|
94
94
|
@authenticated = true
|
95
95
|
response
|
96
96
|
end
|
97
97
|
|
98
|
+
def make_multipart_request(url, data, headers = {})
|
99
|
+
request = Net::HTTP::Post::Multipart.new url, data, headers
|
100
|
+
|
101
|
+
access_token.sign! request
|
102
|
+
|
103
|
+
response = consumer.http.request(request)
|
104
|
+
@authenticated = true
|
105
|
+
response
|
106
|
+
end
|
107
|
+
|
98
108
|
def authenticated?
|
99
109
|
@authenticated
|
100
110
|
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
|
data/lib/jira/version.rb
CHANGED
@@ -33,21 +33,30 @@ describe JIRA::Resource::Watcher do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
describe 'watchers' do
|
36
|
-
|
37
|
-
stub_request(:get,
|
38
|
-
site_url + '/jira/rest/api/2/issue/10002')
|
36
|
+
before(:each) do
|
37
|
+
stub_request(:get, site_url + '/jira/rest/api/2/issue/10002')
|
39
38
|
.to_return(status: 200, body: get_mock_response('issue/10002.json'))
|
40
39
|
|
41
|
-
stub_request(:get,
|
42
|
-
site_url + '/jira/rest/api/2/issue/10002/watchers')
|
40
|
+
stub_request(:get, site_url + '/jira/rest/api/2/issue/10002/watchers')
|
43
41
|
.to_return(status: 200, body: get_mock_response('issue/10002/watchers.json'))
|
44
42
|
|
43
|
+
stub_request(:post, site_url + '/jira/rest/api/2/issue/10002/watchers')
|
44
|
+
.to_return(status: 204, body: nil)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should returns all the watchers' do
|
45
48
|
issue = client.Issue.find('10002')
|
46
49
|
watchers = client.Watcher.all(options = { issue: issue })
|
47
50
|
expect(watchers.length).to eq(1)
|
48
51
|
end
|
52
|
+
|
53
|
+
it 'should add a watcher' do
|
54
|
+
issue = client.Issue.find('10002')
|
55
|
+
watcher = JIRA::Resource::Watcher.new(client, issue: issue)
|
56
|
+
user_id = "tester"
|
57
|
+
watcher.save!(user_id)
|
58
|
+
end
|
49
59
|
end
|
50
60
|
|
51
|
-
it_should_behave_like 'a resource'
|
52
61
|
end
|
53
62
|
end
|
@@ -292,4 +292,37 @@ describe JIRA::HttpClient do
|
|
292
292
|
expect(basic_client).to receive(:http_conn).and_return(http_conn)
|
293
293
|
expect(basic_client.basic_auth_http_conn).to eq(http_conn)
|
294
294
|
end
|
295
|
+
|
296
|
+
describe '#make_multipart_request' do
|
297
|
+
subject do
|
298
|
+
basic_client.make_multipart_request(path, data, headers)
|
299
|
+
end
|
300
|
+
|
301
|
+
let(:path) { '/foo' }
|
302
|
+
let(:data) { {} }
|
303
|
+
let(:headers) { { 'X-Atlassian-Token' => 'no-check' } }
|
304
|
+
let(:basic_auth_http_conn) { double }
|
305
|
+
let(:request) { double('Http Request', path: path) }
|
306
|
+
let(:response) { double('response') }
|
307
|
+
|
308
|
+
before do
|
309
|
+
allow(request).to receive(:basic_auth)
|
310
|
+
allow(Net::HTTP::Post::Multipart).to receive(:new).with(path, data, headers).and_return(request)
|
311
|
+
allow(basic_client).to receive(:basic_auth_http_conn).and_return(basic_auth_http_conn)
|
312
|
+
allow(basic_auth_http_conn).to receive(:request).with(request).and_return(response)
|
313
|
+
end
|
314
|
+
|
315
|
+
it 'performs a basic http client request' do
|
316
|
+
expect(request).to receive(:basic_auth).with(basic_client.options[:username], basic_client.options[:password]).and_return(request)
|
317
|
+
|
318
|
+
subject
|
319
|
+
end
|
320
|
+
|
321
|
+
it 'makes a correct HTTP request' do
|
322
|
+
expect(basic_auth_http_conn).to receive(:request).with(request).and_return(response)
|
323
|
+
expect(response).to receive(:is_a?).with(Net::HTTPOK)
|
324
|
+
|
325
|
+
subject
|
326
|
+
end
|
327
|
+
end
|
295
328
|
end
|
@@ -82,28 +82,45 @@ describe JIRA::OauthClient do
|
|
82
82
|
end
|
83
83
|
|
84
84
|
describe 'http' do
|
85
|
+
let(:headers) { double }
|
86
|
+
let(:access_token) { double }
|
87
|
+
let(:body) { nil }
|
88
|
+
|
89
|
+
before do
|
90
|
+
allow(oauth_client).to receive(:access_token).and_return(access_token)
|
91
|
+
end
|
92
|
+
|
85
93
|
it 'responds to the http methods' do
|
86
|
-
headers = double
|
87
|
-
mock_access_token = double
|
88
|
-
allow(oauth_client).to receive(:access_token).and_return(mock_access_token)
|
89
94
|
%i[delete get head].each do |method|
|
90
|
-
expect(
|
95
|
+
expect(access_token).to receive(method).with('/path', headers).and_return(response)
|
91
96
|
oauth_client.make_request(method, '/path', '', headers)
|
92
97
|
end
|
93
98
|
%i[post put].each do |method|
|
94
|
-
expect(
|
99
|
+
expect(access_token).to receive(method).with('/path', '', headers).and_return(response)
|
95
100
|
oauth_client.make_request(method, '/path', '', headers)
|
96
101
|
end
|
97
102
|
end
|
98
103
|
|
99
104
|
it 'performs a request' do
|
100
|
-
body = nil
|
101
|
-
headers = double
|
102
|
-
access_token = double
|
103
105
|
expect(access_token).to receive(:send).with(:get, '/foo', headers).and_return(response)
|
104
|
-
|
106
|
+
|
107
|
+
|
105
108
|
oauth_client.request(:get, '/foo', body, headers)
|
106
109
|
end
|
110
|
+
|
111
|
+
context 'for a multipart request' do
|
112
|
+
subject { oauth_client.make_multipart_request('/path', data, headers) }
|
113
|
+
|
114
|
+
let(:data) { {} }
|
115
|
+
let(:headers) { {} }
|
116
|
+
|
117
|
+
it 'signs the access_token and performs the request' do
|
118
|
+
expect(access_token).to receive(:sign!).with(an_instance_of(Net::HTTP::Post::Multipart))
|
119
|
+
expect(oauth_client.consumer).to receive_message_chain(:http, :request).with(an_instance_of(Net::HTTP::Post::Multipart))
|
120
|
+
|
121
|
+
subject
|
122
|
+
end
|
123
|
+
end
|
107
124
|
end
|
108
125
|
|
109
126
|
describe 'auth type is oauth_2legged' do
|
@@ -142,4 +159,4 @@ describe JIRA::OauthClient do
|
|
142
159
|
end
|
143
160
|
end
|
144
161
|
end
|
145
|
-
end
|
162
|
+
end
|
@@ -1,14 +1,41 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe JIRA::RequestClient do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
let(:request_client) { JIRA::RequestClient.new }
|
5
|
+
|
6
|
+
describe '#request' do
|
7
|
+
subject(:request) { request_client.request(:get, '/foo', '', {}) }
|
8
|
+
|
9
|
+
context 'when doing a request fails' do
|
10
|
+
let(:response) { double }
|
11
|
+
|
12
|
+
before do
|
13
|
+
allow(response).to receive(:kind_of?).with(Net::HTTPSuccess).and_return(false)
|
14
|
+
allow(request_client).to receive(:make_request).with(:get, '/foo', '', {}).and_return(response)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'raises an exception' do
|
18
|
+
expect{ subject }.to raise_exception(JIRA::HTTPError)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#request_multipart' do
|
24
|
+
subject(:request) { request_client.request_multipart('/foo', data, {}) }
|
25
|
+
|
26
|
+
let(:data) { double }
|
27
|
+
|
28
|
+
context 'when doing a request fails' do
|
29
|
+
let(:response) { double }
|
30
|
+
|
31
|
+
before do
|
32
|
+
allow(response).to receive(:kind_of?).with(Net::HTTPSuccess).and_return(false)
|
33
|
+
allow(request_client).to receive(:make_multipart_request).with('/foo', data, {}).and_return(response)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'raises an exception' do
|
37
|
+
expect{ subject }.to raise_exception(JIRA::HTTPError)
|
38
|
+
end
|
39
|
+
end
|
13
40
|
end
|
14
|
-
end
|
41
|
+
end
|
@@ -1,6 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe JIRA::Resource::Attachment do
|
4
|
+
subject(:attachment) do
|
5
|
+
JIRA::Resource::Attachment.new(
|
6
|
+
client,
|
7
|
+
issue: JIRA::Resource::Issue.new(client),
|
8
|
+
attrs: { 'author' => { 'foo' => 'bar' } }
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
4
12
|
let(:client) do
|
5
13
|
double(
|
6
14
|
'client',
|
@@ -17,42 +25,78 @@ describe JIRA::Resource::Attachment do
|
|
17
25
|
end
|
18
26
|
|
19
27
|
describe 'relationships' do
|
20
|
-
|
21
|
-
JIRA::Resource::
|
22
|
-
issue: JIRA::Resource::Issue.new(client),
|
23
|
-
attrs: { 'author' => { 'foo' => 'bar' } })
|
28
|
+
it 'has an author' do
|
29
|
+
expect(subject).to have_one(:author, JIRA::Resource::User)
|
24
30
|
end
|
25
31
|
|
26
|
-
it 'has the correct
|
27
|
-
expect(subject).to have_one(:author, JIRA::Resource::User)
|
32
|
+
it 'has the correct author name' do
|
28
33
|
expect(subject.author.foo).to eq('bar')
|
29
34
|
end
|
30
35
|
end
|
31
36
|
|
32
|
-
describe '
|
37
|
+
describe '.meta' do
|
38
|
+
subject { JIRA::Resource::Attachment.meta(client) }
|
39
|
+
|
33
40
|
let(:response) do
|
34
41
|
double(
|
35
|
-
|
36
|
-
|
42
|
+
'response',
|
43
|
+
body: '{"enabled":true,"uploadLimit":10485760}'
|
37
44
|
)
|
38
45
|
end
|
39
46
|
|
40
47
|
it 'returns meta information about attachment upload' do
|
41
48
|
expect(client).to receive(:get).with('/jira/rest/api/2/attachment/meta').and_return(response)
|
42
|
-
|
49
|
+
|
50
|
+
subject
|
43
51
|
end
|
44
52
|
|
45
|
-
|
53
|
+
context 'the factory delegates correctly' do
|
54
|
+
subject { JIRA::Resource::AttachmentFactory.new(client) }
|
46
55
|
|
47
|
-
|
48
|
-
|
56
|
+
it 'delegates #meta to to target class' do
|
57
|
+
expect(subject).to respond_to(:meta)
|
58
|
+
end
|
49
59
|
end
|
50
60
|
end
|
51
61
|
|
52
|
-
describe '#save
|
62
|
+
describe '#save' do
|
63
|
+
subject { attachment.save('file' => path_to_file) }
|
64
|
+
let(:path_to_file) { './spec/mock_responses/issue.json' }
|
65
|
+
let(:response) do
|
66
|
+
double(
|
67
|
+
body: [
|
68
|
+
{
|
69
|
+
"id": 10_001,
|
70
|
+
"self": 'http://www.example.com/jira/rest/api/2.0/attachments/10000',
|
71
|
+
"filename": 'picture.jpg',
|
72
|
+
"created": '2017-07-19T12:23:06.572+0000',
|
73
|
+
"size": 23_123,
|
74
|
+
"mimeType": 'image/jpeg'
|
75
|
+
}
|
76
|
+
].to_json
|
77
|
+
)
|
78
|
+
end
|
79
|
+
let(:issue) { JIRA::Resource::Issue.new(client) }
|
80
|
+
|
81
|
+
before do
|
82
|
+
allow(client).to receive(:post_multipart).and_return(response)
|
83
|
+
end
|
84
|
+
|
53
85
|
it 'successfully update the attachment' do
|
54
|
-
|
55
|
-
|
86
|
+
subject
|
87
|
+
|
88
|
+
expect(attachment.filename).to eq 'picture.jpg'
|
89
|
+
expect(attachment.mimeType).to eq 'image/jpeg'
|
90
|
+
expect(attachment.size).to eq 23_123
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '#save!' do
|
95
|
+
subject { attachment.save!('file' => path_to_file) }
|
96
|
+
|
97
|
+
let(:path_to_file) { './spec/mock_responses/issue.json' }
|
98
|
+
let(:response) do
|
99
|
+
double(
|
56
100
|
body: [
|
57
101
|
{
|
58
102
|
"id": 10_001,
|
@@ -64,18 +108,31 @@ describe JIRA::Resource::Attachment do
|
|
64
108
|
}
|
65
109
|
].to_json
|
66
110
|
)
|
111
|
+
end
|
112
|
+
let(:issue) { JIRA::Resource::Issue.new(client) }
|
67
113
|
|
68
|
-
|
69
|
-
allow(
|
114
|
+
before do
|
115
|
+
allow(client).to receive(:post_multipart).and_return(response)
|
116
|
+
end
|
70
117
|
|
71
|
-
|
72
|
-
|
73
|
-
attachment = JIRA::Resource::Attachment.new(client, issue: issue)
|
74
|
-
attachment.save!('file' => path_to_file)
|
118
|
+
it 'successfully update the attachment' do
|
119
|
+
subject
|
75
120
|
|
76
121
|
expect(attachment.filename).to eq 'picture.jpg'
|
77
122
|
expect(attachment.mimeType).to eq 'image/jpeg'
|
78
123
|
expect(attachment.size).to eq 23_123
|
79
124
|
end
|
125
|
+
|
126
|
+
context 'when passing in a symbol as file key' do
|
127
|
+
subject { attachment.save!(file: path_to_file) }
|
128
|
+
|
129
|
+
it 'successfully update the attachment' do
|
130
|
+
subject
|
131
|
+
|
132
|
+
expect(attachment.filename).to eq 'picture.jpg'
|
133
|
+
expect(attachment.mimeType).to eq 'image/jpeg'
|
134
|
+
expect(attachment.size).to eq 23_123
|
135
|
+
end
|
136
|
+
end
|
80
137
|
end
|
81
138
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jira-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SUMO Heavy Industries
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-03-
|
12
|
+
date: 2020-03-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -57,42 +57,42 @@ dependencies:
|
|
57
57
|
name: oauth
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- - ">="
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 0.5.0
|
63
60
|
- - "~>"
|
64
61
|
- !ruby/object:Gem::Version
|
65
62
|
version: '0.5'
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 0.5.0
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
68
|
version_requirements: !ruby/object:Gem::Requirement
|
69
69
|
requirements:
|
70
|
-
- - ">="
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version: 0.5.0
|
73
70
|
- - "~>"
|
74
71
|
- !ruby/object:Gem::Version
|
75
72
|
version: '0.5'
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.5.0
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
name: guard
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 2.13.0
|
83
80
|
- - "~>"
|
84
81
|
- !ruby/object:Gem::Version
|
85
82
|
version: '2.13'
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 2.13.0
|
86
86
|
type: :development
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
89
|
requirements:
|
90
|
-
- - ">="
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
version: 2.13.0
|
93
90
|
- - "~>"
|
94
91
|
- !ruby/object:Gem::Version
|
95
92
|
version: '2.13'
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 2.13.0
|
96
96
|
- !ruby/object:Gem::Dependency
|
97
97
|
name: guard-rspec
|
98
98
|
requirement: !ruby/object:Gem::Requirement
|
@@ -171,42 +171,42 @@ dependencies:
|
|
171
171
|
name: rspec
|
172
172
|
requirement: !ruby/object:Gem::Requirement
|
173
173
|
requirements:
|
174
|
-
- - ">="
|
175
|
-
- !ruby/object:Gem::Version
|
176
|
-
version: 3.0.0
|
177
174
|
- - "~>"
|
178
175
|
- !ruby/object:Gem::Version
|
179
176
|
version: '3.0'
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: 3.0.0
|
180
180
|
type: :development
|
181
181
|
prerelease: false
|
182
182
|
version_requirements: !ruby/object:Gem::Requirement
|
183
183
|
requirements:
|
184
|
-
- - ">="
|
185
|
-
- !ruby/object:Gem::Version
|
186
|
-
version: 3.0.0
|
187
184
|
- - "~>"
|
188
185
|
- !ruby/object:Gem::Version
|
189
186
|
version: '3.0'
|
187
|
+
- - ">="
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: 3.0.0
|
190
190
|
- !ruby/object:Gem::Dependency
|
191
191
|
name: webmock
|
192
192
|
requirement: !ruby/object:Gem::Requirement
|
193
193
|
requirements:
|
194
|
-
- - ">="
|
195
|
-
- !ruby/object:Gem::Version
|
196
|
-
version: 1.18.0
|
197
194
|
- - "~>"
|
198
195
|
- !ruby/object:Gem::Version
|
199
196
|
version: '1.18'
|
197
|
+
- - ">="
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: 1.18.0
|
200
200
|
type: :development
|
201
201
|
prerelease: false
|
202
202
|
version_requirements: !ruby/object:Gem::Requirement
|
203
203
|
requirements:
|
204
|
-
- - ">="
|
205
|
-
- !ruby/object:Gem::Version
|
206
|
-
version: 1.18.0
|
207
204
|
- - "~>"
|
208
205
|
- !ruby/object:Gem::Version
|
209
206
|
version: '1.18'
|
207
|
+
- - ">="
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: 1.18.0
|
210
210
|
description: API for JIRA
|
211
211
|
email:
|
212
212
|
executables: []
|
@@ -385,7 +385,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
385
385
|
- !ruby/object:Gem::Version
|
386
386
|
version: '0'
|
387
387
|
requirements: []
|
388
|
-
|
388
|
+
rubyforge_project:
|
389
|
+
rubygems_version: 2.5.1
|
389
390
|
signing_key:
|
390
391
|
specification_version: 4
|
391
392
|
summary: Ruby Gem for use with the Atlassian JIRA REST API
|