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
@@ -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
|
data/spec/jira/base_spec.rb
CHANGED
@@ -369,6 +369,18 @@ describe JIRA::Base do
|
|
369
369
|
expect(subject.url).to eq('http://foo/bar')
|
370
370
|
end
|
371
371
|
|
372
|
+
it 'returns path as the URL if set and site options is specified' do
|
373
|
+
allow(client).to receive(:options) { { site: 'http://foo' } }
|
374
|
+
attrs['self'] = 'http://foo/bar'
|
375
|
+
expect(subject.url).to eq('/bar')
|
376
|
+
end
|
377
|
+
|
378
|
+
it 'returns path as the URL if set and site options is specified and ends with a slash' do
|
379
|
+
allow(client).to receive(:options) { { site: 'http://foo/' } }
|
380
|
+
attrs['self'] = 'http://foo/bar'
|
381
|
+
expect(subject.url).to eq('/bar')
|
382
|
+
end
|
383
|
+
|
372
384
|
it 'generates the URL from id if self not set' do
|
373
385
|
attrs['self'] = nil
|
374
386
|
attrs['id'] = '98765'
|
data/spec/jira/client_spec.rb
CHANGED
@@ -59,6 +59,19 @@ RSpec.shared_examples 'Client Common Tests' do
|
|
59
59
|
expect(subject.Project.find('123')).to eq(find_result)
|
60
60
|
end
|
61
61
|
end
|
62
|
+
|
63
|
+
describe 'SSL client options' do
|
64
|
+
context 'without certificate and key' do
|
65
|
+
let(:options) { { use_client_cert: true } }
|
66
|
+
subject { JIRA::Client.new(options) }
|
67
|
+
|
68
|
+
it 'raises an ArgumentError' do
|
69
|
+
expect { subject }.to raise_exception(ArgumentError, 'Options: :cert_path or :ssl_client_cert must be set when :use_client_cert is true')
|
70
|
+
options[:ssl_client_cert] = '<cert></cert>'
|
71
|
+
expect { subject }.to raise_exception(ArgumentError, 'Options: :key_path or :ssl_client_key must be set when :use_client_cert is true')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
62
75
|
end
|
63
76
|
|
64
77
|
RSpec.shared_examples 'HttpClient tests' do
|
@@ -266,4 +279,13 @@ describe JIRA::Client do
|
|
266
279
|
|
267
280
|
include_examples 'OAuth Common Tests'
|
268
281
|
end
|
282
|
+
|
283
|
+
context 'with unknown options' do
|
284
|
+
let(:options) { { 'username' => 'foo', 'password' => 'bar', auth_type: :basic } }
|
285
|
+
subject { JIRA::Client.new(options) }
|
286
|
+
|
287
|
+
it 'raises an ArgumentError' do
|
288
|
+
expect { subject }.to raise_exception(ArgumentError, 'Unknown option(s) given: ["username", "password"]')
|
289
|
+
end
|
290
|
+
end
|
269
291
|
end
|
@@ -280,8 +280,8 @@ describe JIRA::HttpClient do
|
|
280
280
|
expect(http_conn).to receive(:use_ssl=).with(basic_client.options[:use_ssl])
|
281
281
|
expect(http_conn).to receive(:verify_mode=).with(basic_client.options[:ssl_verify_mode])
|
282
282
|
expect(http_conn).to receive(:read_timeout=).with(basic_client.options[:read_timeout])
|
283
|
-
expect(http_conn).to receive(:cert=).with(basic_client_cert_client.options[:
|
284
|
-
expect(http_conn).to receive(:key=).with(basic_client_cert_client.options[:
|
283
|
+
expect(http_conn).to receive(:cert=).with(basic_client_cert_client.options[:ssl_client_cert])
|
284
|
+
expect(http_conn).to receive(:key=).with(basic_client_cert_client.options[:ssl_client_key])
|
285
285
|
expect(basic_client_cert_client.http_conn(uri)).to eq(http_conn)
|
286
286
|
end
|
287
287
|
|
@@ -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
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::IssuePickerSuggestions do
|
4
|
+
let(:client) do
|
5
|
+
double('client', options: {
|
6
|
+
rest_base_path: '/jira/rest/api/2'
|
7
|
+
})
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'relationships' do
|
11
|
+
subject do
|
12
|
+
JIRA::Resource::IssuePickerSuggestions.new(client, attrs: {
|
13
|
+
'sections' => [{ 'id' => 'hs'}, { 'id' => 'cs' }]
|
14
|
+
})
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'has the correct relationships' do
|
18
|
+
expect(subject).to have_many(:sections, JIRA::Resource::IssuePickerSuggestionsIssue)
|
19
|
+
expect(subject.sections.length).to eq(2)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#all' do
|
24
|
+
let(:response) { double }
|
25
|
+
let(:issue_picker_suggestions) { double }
|
26
|
+
|
27
|
+
before do
|
28
|
+
allow(response).to receive(:body).and_return('{"sections":[{"id": "cs"}]}')
|
29
|
+
allow(client).to receive(:IssuePickerSuggestions).and_return(issue_picker_suggestions)
|
30
|
+
allow(issue_picker_suggestions).to receive(:build)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should autocomplete issues' do
|
34
|
+
allow(response).to receive(:body).and_return('{"sections":[{"id": "cs"}]}')
|
35
|
+
expect(client).to receive(:get).with('/jira/rest/api/2/issue/picker?query=query')
|
36
|
+
.and_return(response)
|
37
|
+
|
38
|
+
expect(client).to receive(:IssuePickerSuggestions).and_return(issue_picker_suggestions)
|
39
|
+
expect(issue_picker_suggestions).to receive(:build).with('sections' => [{ 'id' => 'cs' }])
|
40
|
+
|
41
|
+
JIRA::Resource::IssuePickerSuggestions.all(client, 'query')
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should autocomplete issues with current jql' do
|
45
|
+
expect(client).to receive(:get).with('/jira/rest/api/2/issue/picker?query=query¤tJQL=project+%3D+PR')
|
46
|
+
.and_return(response)
|
47
|
+
|
48
|
+
JIRA::Resource::IssuePickerSuggestions.all(client, 'query', current_jql: 'project = PR')
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should autocomplete issues with current issue jey' do
|
52
|
+
expect(client).to receive(:get).with('/jira/rest/api/2/issue/picker?query=query¤tIssueKey=PR-42')
|
53
|
+
.and_return(response)
|
54
|
+
|
55
|
+
JIRA::Resource::IssuePickerSuggestions.all(client, 'query', current_issue_key: 'PR-42')
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should autocomplete issues with current project id' do
|
59
|
+
expect(client).to receive(:get).with('/jira/rest/api/2/issue/picker?query=query¤tProjectId=PR')
|
60
|
+
.and_return(response)
|
61
|
+
|
62
|
+
JIRA::Resource::IssuePickerSuggestions.all(client, 'query', current_project_id: 'PR')
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should autocomplete issues with show sub tasks' do
|
66
|
+
expect(client).to receive(:get).with('/jira/rest/api/2/issue/picker?query=query&showSubTasks=true')
|
67
|
+
.and_return(response)
|
68
|
+
|
69
|
+
JIRA::Resource::IssuePickerSuggestions.all(client, 'query', show_sub_tasks: true)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should autocomplete issues with show sub tasks parent' do
|
73
|
+
expect(client).to receive(:get).with('/jira/rest/api/2/issue/picker?query=query&showSubTaskParent=true')
|
74
|
+
.and_return(response)
|
75
|
+
|
76
|
+
JIRA::Resource::IssuePickerSuggestions.all(client, 'query', show_sub_task_parent: true)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::IssuePickerSuggestionsIssue do
|
4
|
+
let(:client) { double('client') }
|
5
|
+
|
6
|
+
describe 'relationships' do
|
7
|
+
subject do
|
8
|
+
JIRA::Resource::IssuePickerSuggestionsIssue.new(client, attrs: {
|
9
|
+
'issues' => [{ 'id' => '1'}, { 'id' => '2' }]
|
10
|
+
})
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'has the correct relationships' do
|
14
|
+
expect(subject).to have_many(:issues, JIRA::Resource::SuggestedIssue)
|
15
|
+
expect(subject.issues.length).to eq(2)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,12 +1,25 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe JIRA::Resource::Sprint do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
let(:client) do
|
5
|
+
client = double(options: { site: 'https://foo.bar.com', context_path: '/jira' })
|
6
|
+
allow(client).to receive(:Sprint).and_return(JIRA::Resource::SprintFactory.new(client))
|
7
|
+
client
|
8
|
+
end
|
9
|
+
let(:sprint) { described_class.new(client) }
|
10
|
+
let(:agile_sprint_path) { "#{sprint.client.options[:context_path]}/rest/agile/1.0/sprint/#{sprint.id}" }
|
7
11
|
|
12
|
+
describe '::find' do
|
13
|
+
let(:response) { double('Response', body: '{"some_detail":"some detail"}') }
|
14
|
+
|
15
|
+
it 'fetches the sprint from JIRA' do
|
16
|
+
expect(client).to receive(:get).with('/jira/rest/agile/1.0/sprint/111').and_return(response)
|
17
|
+
expect(JIRA::Resource::Sprint.find(client, '111')).to be_a(JIRA::Resource::Sprint)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'peristence' do
|
8
22
|
describe '#save' do
|
9
|
-
let(:agile_sprint_url) { "#{sprint.client.options[:site]}/rest/agile/1.0/sprint/#{sprint.id}" }
|
10
23
|
let(:instance_attrs) { { start_date: '2016-06-01' } }
|
11
24
|
|
12
25
|
before do
|
@@ -17,7 +30,7 @@ describe JIRA::Resource::Sprint do
|
|
17
30
|
let(:given_attrs) { { start_date: '2016-06-10' } }
|
18
31
|
|
19
32
|
it 'calls save on the super class with the given attributes & agile url' do
|
20
|
-
expect_any_instance_of(JIRA::Base).to receive(:save).with(given_attrs,
|
33
|
+
expect_any_instance_of(JIRA::Base).to receive(:save).with(given_attrs, agile_sprint_path)
|
21
34
|
|
22
35
|
sprint.save(given_attrs)
|
23
36
|
end
|
@@ -25,7 +38,7 @@ describe JIRA::Resource::Sprint do
|
|
25
38
|
|
26
39
|
context 'when attributes are not specified' do
|
27
40
|
it 'calls save on the super class with the instance attributes & agile url' do
|
28
|
-
expect_any_instance_of(JIRA::Base).to receive(:save).with(instance_attrs,
|
41
|
+
expect_any_instance_of(JIRA::Base).to receive(:save).with(instance_attrs, agile_sprint_path)
|
29
42
|
|
30
43
|
sprint.save
|
31
44
|
end
|
@@ -33,7 +46,7 @@ describe JIRA::Resource::Sprint do
|
|
33
46
|
|
34
47
|
context 'when providing the path argument' do
|
35
48
|
it 'ignores it' do
|
36
|
-
expect_any_instance_of(JIRA::Base).to receive(:save).with(instance_attrs,
|
49
|
+
expect_any_instance_of(JIRA::Base).to receive(:save).with(instance_attrs, agile_sprint_path)
|
37
50
|
|
38
51
|
sprint.save({}, 'mavenlink.com')
|
39
52
|
end
|
@@ -41,7 +54,6 @@ describe JIRA::Resource::Sprint do
|
|
41
54
|
end
|
42
55
|
|
43
56
|
describe '#save!' do
|
44
|
-
let(:agile_sprint_url) { "#{sprint.client.options[:site]}/rest/agile/1.0/sprint/#{sprint.id}" }
|
45
57
|
let(:instance_attrs) { { start_date: '2016-06-01' } }
|
46
58
|
|
47
59
|
before do
|
@@ -52,7 +64,7 @@ describe JIRA::Resource::Sprint do
|
|
52
64
|
let(:given_attrs) { { start_date: '2016-06-10' } }
|
53
65
|
|
54
66
|
it 'calls save! on the super class with the given attributes & agile url' do
|
55
|
-
expect_any_instance_of(JIRA::Base).to receive(:save!).with(given_attrs,
|
67
|
+
expect_any_instance_of(JIRA::Base).to receive(:save!).with(given_attrs, agile_sprint_path)
|
56
68
|
|
57
69
|
sprint.save!(given_attrs)
|
58
70
|
end
|
@@ -60,7 +72,7 @@ describe JIRA::Resource::Sprint do
|
|
60
72
|
|
61
73
|
context 'when attributes are not specified' do
|
62
74
|
it 'calls save! on the super class with the instance attributes & agile url' do
|
63
|
-
expect_any_instance_of(JIRA::Base).to receive(:save!).with(instance_attrs,
|
75
|
+
expect_any_instance_of(JIRA::Base).to receive(:save!).with(instance_attrs, agile_sprint_path)
|
64
76
|
|
65
77
|
sprint.save!
|
66
78
|
end
|
@@ -68,7 +80,7 @@ describe JIRA::Resource::Sprint do
|
|
68
80
|
|
69
81
|
context 'when providing the path argument' do
|
70
82
|
it 'ignores it' do
|
71
|
-
expect_any_instance_of(JIRA::Base).to receive(:save!).with(instance_attrs,
|
83
|
+
expect_any_instance_of(JIRA::Base).to receive(:save!).with(instance_attrs, agile_sprint_path)
|
72
84
|
|
73
85
|
sprint.save!({}, 'mavenlink.com')
|
74
86
|
end
|