jira-ruby 2.2.0 → 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +20 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  4. data/.github/dependabot.yml +6 -0
  5. data/.github/workflows/CI.yml +28 -0
  6. data/.github/workflows/codeql.yml +100 -0
  7. data/.github/workflows/rubocop.yml +18 -0
  8. data/.rubocop.yml +188 -0
  9. data/Gemfile +11 -3
  10. data/Guardfile +2 -0
  11. data/README.md +121 -20
  12. data/Rakefile +4 -5
  13. data/jira-ruby.gemspec +11 -17
  14. data/lib/jira/base.rb +37 -28
  15. data/lib/jira/base_factory.rb +4 -1
  16. data/lib/jira/client.rb +65 -46
  17. data/lib/jira/has_many_proxy.rb +4 -2
  18. data/lib/jira/http_client.rb +18 -13
  19. data/lib/jira/http_error.rb +4 -0
  20. data/lib/jira/jwt_client.rb +18 -42
  21. data/lib/jira/oauth_client.rb +6 -3
  22. data/lib/jira/railtie.rb +2 -0
  23. data/lib/jira/request_client.rb +5 -1
  24. data/lib/jira/resource/agile.rb +7 -9
  25. data/lib/jira/resource/applinks.rb +5 -3
  26. data/lib/jira/resource/attachment.rb +43 -3
  27. data/lib/jira/resource/board.rb +5 -3
  28. data/lib/jira/resource/board_configuration.rb +2 -0
  29. data/lib/jira/resource/comment.rb +2 -0
  30. data/lib/jira/resource/component.rb +2 -0
  31. data/lib/jira/resource/createmeta.rb +3 -1
  32. data/lib/jira/resource/field.rb +9 -4
  33. data/lib/jira/resource/filter.rb +2 -0
  34. data/lib/jira/resource/issue.rb +35 -44
  35. data/lib/jira/resource/issue_picker_suggestions.rb +4 -1
  36. data/lib/jira/resource/issue_picker_suggestions_issue.rb +2 -0
  37. data/lib/jira/resource/issuelink.rb +2 -0
  38. data/lib/jira/resource/issuelinktype.rb +2 -0
  39. data/lib/jira/resource/issuetype.rb +2 -0
  40. data/lib/jira/resource/priority.rb +2 -0
  41. data/lib/jira/resource/project.rb +4 -2
  42. data/lib/jira/resource/rapidview.rb +5 -3
  43. data/lib/jira/resource/remotelink.rb +2 -0
  44. data/lib/jira/resource/resolution.rb +2 -0
  45. data/lib/jira/resource/serverinfo.rb +2 -0
  46. data/lib/jira/resource/sprint.rb +14 -23
  47. data/lib/jira/resource/status.rb +7 -1
  48. data/lib/jira/resource/status_category.rb +10 -0
  49. data/lib/jira/resource/suggested_issue.rb +2 -0
  50. data/lib/jira/resource/transition.rb +2 -0
  51. data/lib/jira/resource/user.rb +3 -1
  52. data/lib/jira/resource/version.rb +2 -0
  53. data/lib/jira/resource/watcher.rb +2 -1
  54. data/lib/jira/resource/webhook.rb +4 -2
  55. data/lib/jira/resource/worklog.rb +3 -2
  56. data/lib/jira/version.rb +3 -1
  57. data/lib/jira-ruby.rb +5 -3
  58. data/lib/tasks/generate.rake +4 -2
  59. data/spec/data/files/short.txt +1 -0
  60. data/spec/integration/attachment_spec.rb +3 -3
  61. data/spec/integration/comment_spec.rb +8 -8
  62. data/spec/integration/component_spec.rb +7 -7
  63. data/spec/integration/field_spec.rb +3 -3
  64. data/spec/integration/issue_spec.rb +20 -16
  65. data/spec/integration/issuelinktype_spec.rb +3 -3
  66. data/spec/integration/issuetype_spec.rb +3 -3
  67. data/spec/integration/priority_spec.rb +3 -3
  68. data/spec/integration/project_spec.rb +7 -7
  69. data/spec/integration/rapidview_spec.rb +9 -9
  70. data/spec/integration/resolution_spec.rb +3 -3
  71. data/spec/integration/status_category_spec.rb +20 -0
  72. data/spec/integration/status_spec.rb +4 -8
  73. data/spec/integration/transition_spec.rb +2 -2
  74. data/spec/integration/user_spec.rb +22 -8
  75. data/spec/integration/version_spec.rb +7 -7
  76. data/spec/integration/watcher_spec.rb +17 -18
  77. data/spec/integration/webhook.rb +5 -4
  78. data/spec/integration/worklog_spec.rb +8 -8
  79. data/spec/jira/base_factory_spec.rb +2 -1
  80. data/spec/jira/base_spec.rb +55 -41
  81. data/spec/jira/client_spec.rb +48 -34
  82. data/spec/jira/has_many_proxy_spec.rb +3 -3
  83. data/spec/jira/http_client_spec.rb +98 -26
  84. data/spec/jira/http_error_spec.rb +2 -2
  85. data/spec/jira/oauth_client_spec.rb +30 -8
  86. data/spec/jira/request_client_spec.rb +4 -4
  87. data/spec/jira/resource/agile_spec.rb +28 -28
  88. data/spec/jira/resource/attachment_spec.rb +142 -52
  89. data/spec/jira/resource/board_spec.rb +21 -20
  90. data/spec/jira/resource/createmeta_spec.rb +48 -48
  91. data/spec/jira/resource/field_spec.rb +30 -12
  92. data/spec/jira/resource/filter_spec.rb +4 -4
  93. data/spec/jira/resource/issue_picker_suggestions_spec.rb +18 -18
  94. data/spec/jira/resource/issue_spec.rb +44 -38
  95. data/spec/jira/resource/jira_picker_suggestions_issue_spec.rb +3 -3
  96. data/spec/jira/resource/project_factory_spec.rb +3 -2
  97. data/spec/jira/resource/project_spec.rb +16 -16
  98. data/spec/jira/resource/sprint_spec.rb +70 -3
  99. data/spec/jira/resource/status_spec.rb +21 -0
  100. data/spec/jira/resource/user_factory_spec.rb +4 -4
  101. data/spec/jira/resource/worklog_spec.rb +3 -3
  102. data/spec/mock_responses/sprint/1.json +13 -0
  103. data/spec/mock_responses/status/1.json +8 -1
  104. data/spec/mock_responses/status.json +40 -5
  105. data/spec/mock_responses/statuscategory/1.json +7 -0
  106. data/spec/mock_responses/statuscategory.json +30 -0
  107. data/spec/mock_responses/{user_username=admin.json → user_accountId=1234567890abcdef01234567.json} +2 -1
  108. data/spec/spec_helper.rb +1 -0
  109. data/spec/support/clients_helper.rb +3 -5
  110. data/spec/support/shared_examples/integration.rb +25 -28
  111. metadata +25 -257
  112. data/.travis.yml +0 -9
  113. data/example.rb +0 -232
  114. data/http-basic-example.rb +0 -113
  115. data/lib/jira/resource/sprint_report.rb +0 -8
  116. data/lib/jira/tasks.rb +0 -0
  117. data/spec/jira/jwt_uri_builder_spec.rb +0 -59
@@ -5,7 +5,7 @@ describe JIRA::HttpClient do
5
5
  options = JIRA::Client::DEFAULT_OPTIONS
6
6
  .merge(JIRA::HttpClient::DEFAULT_OPTIONS)
7
7
  .merge(basic_auth_credentials)
8
- JIRA::HttpClient.new(options)
8
+ described_class.new(options)
9
9
  end
10
10
 
11
11
  let(:basic_cookie_client) do
@@ -13,12 +13,12 @@ describe JIRA::HttpClient do
13
13
  .merge(JIRA::HttpClient::DEFAULT_OPTIONS)
14
14
  .merge(use_cookies: true)
15
15
  .merge(basic_auth_credentials)
16
- JIRA::HttpClient.new(options)
16
+ described_class.new(options)
17
17
  end
18
18
 
19
19
  let(:custom_ssl_version_client) do
20
20
  options = JIRA::Client::DEFAULT_OPTIONS.merge(JIRA::HttpClient::DEFAULT_OPTIONS).merge(ssl_version: :TLSv1_2)
21
- JIRA::HttpClient.new(options)
21
+ described_class.new(options)
22
22
  end
23
23
 
24
24
  let(:basic_cookie_client_with_context_path) do
@@ -26,7 +26,7 @@ describe JIRA::HttpClient do
26
26
  use_cookies: true,
27
27
  context_path: '/context'
28
28
  )
29
- JIRA::HttpClient.new(options)
29
+ described_class.new(options)
30
30
  end
31
31
 
32
32
  let(:basic_cookie_client_with_additional_cookies) do
@@ -37,7 +37,7 @@ describe JIRA::HttpClient do
37
37
  additional_cookies: ['sessionToken=abc123', 'internal=true']
38
38
  )
39
39
  .merge(basic_auth_credentials)
40
- JIRA::HttpClient.new(options)
40
+ described_class.new(options)
41
41
  end
42
42
 
43
43
  let(:basic_client_cert_client) do
@@ -46,13 +46,13 @@ describe JIRA::HttpClient do
46
46
  cert: 'public certificate contents',
47
47
  key: 'private key contents'
48
48
  )
49
- JIRA::HttpClient.new(options)
49
+ described_class.new(options)
50
50
  end
51
51
 
52
52
  let(:basic_client_with_no_auth_credentials) do
53
53
  options = JIRA::Client::DEFAULT_OPTIONS
54
54
  .merge(JIRA::HttpClient::DEFAULT_OPTIONS)
55
- JIRA::HttpClient.new(options)
55
+ described_class.new(options)
56
56
  end
57
57
 
58
58
  let(:basic_auth_credentials) do
@@ -66,7 +66,14 @@ describe JIRA::HttpClient do
66
66
  proxy_username: 'proxyUsername',
67
67
  proxy_password: 'proxyPassword'
68
68
  )
69
- JIRA::HttpClient.new(options)
69
+ described_class.new(options)
70
+ end
71
+
72
+ let(:basic_client_with_max_retries) do
73
+ options = JIRA::Client::DEFAULT_OPTIONS.merge(JIRA::HttpClient::DEFAULT_OPTIONS).merge(
74
+ max_retries: 2
75
+ )
76
+ described_class.new(options)
70
77
  end
71
78
 
72
79
  let(:response) do
@@ -81,6 +88,35 @@ describe JIRA::HttpClient do
81
88
  response
82
89
  end
83
90
 
91
+ context 'simple client' do
92
+ let(:client) do
93
+ options_local = JIRA::Client::DEFAULT_OPTIONS.merge(JIRA::HttpClient::DEFAULT_OPTIONS).merge(
94
+ proxy_address: 'proxyAddress',
95
+ proxy_port: 42,
96
+ proxy_username: 'proxyUsername',
97
+ proxy_password: 'proxyPassword'
98
+ )
99
+ described_class.new(options_local)
100
+ end
101
+
102
+ describe 'HttpClient#basic_auth_http_conn' do
103
+ subject(:http_conn) { basic_client.basic_auth_http_conn }
104
+
105
+ it 'creates an instance of Net:HTTP for a basic auth client' do
106
+ expect(http_conn.class).to eq(Net::HTTP)
107
+ end
108
+
109
+ it 'the connection created has no proxy' do
110
+ http_conn
111
+
112
+ expect(http_conn.proxy_address).to be_nil
113
+ expect(http_conn.proxy_port).to be_nil
114
+ expect(http_conn.proxy_user).to be_nil
115
+ expect(http_conn.proxy_pass).to be_nil
116
+ end
117
+ end
118
+ end
119
+
84
120
  it 'creates an instance of Net:HTTP for a basic auth client' do
85
121
  expect(basic_client.basic_auth_http_conn.class).to eq(Net::HTTP)
86
122
  end
@@ -111,7 +147,8 @@ describe JIRA::HttpClient do
111
147
  basic_auth_http_conn = double
112
148
  request = double
113
149
  allow(basic_client).to receive(:basic_auth_http_conn).and_return(basic_auth_http_conn)
114
- expect(request).to receive(:basic_auth).with(basic_client.options[:username], basic_client.options[:password]).exactly(5).times.and_return(request)
150
+ expect(request).to receive(:basic_auth).with(basic_client.options[:username],
151
+ basic_client.options[:password]).exactly(5).times.and_return(request)
115
152
  expect(basic_auth_http_conn).to receive(:request).exactly(5).times.with(request).and_return(response)
116
153
  %i[delete get head].each do |method|
117
154
  expect(Net::HTTP.const_get(method.to_s.capitalize)).to receive(:new).with('/path', headers).and_return(request)
@@ -130,7 +167,8 @@ describe JIRA::HttpClient do
130
167
  basic_auth_http_conn = double
131
168
  request = double
132
169
  allow(basic_cookie_client).to receive(:basic_auth_http_conn).and_return(basic_auth_http_conn)
133
- expect(request).to receive(:basic_auth).with(basic_cookie_client.options[:username], basic_cookie_client.options[:password]).exactly(5).times.and_return(request)
170
+ expect(request).to receive(:basic_auth).with(basic_cookie_client.options[:username],
171
+ basic_cookie_client.options[:password]).exactly(5).times.and_return(request)
134
172
  expect(cookie_response).to receive(:get_fields).with('set-cookie').exactly(5).times
135
173
  expect(basic_auth_http_conn).to receive(:request).exactly(5).times.with(request).and_return(cookie_response)
136
174
  %i[delete get head].each do |method|
@@ -151,7 +189,8 @@ describe JIRA::HttpClient do
151
189
  basic_auth_http_conn = double
152
190
  request = double
153
191
  allow(client).to receive(:basic_auth_http_conn).and_return(basic_auth_http_conn)
154
- expect(request).to receive(:basic_auth).with(client.options[:username], client.options[:password]).exactly(5).times.and_return(request)
192
+ expect(request).to receive(:basic_auth).with(client.options[:username],
193
+ client.options[:password]).exactly(5).times.and_return(request)
155
194
  expect(request).to receive(:add_field).with('Cookie', 'sessionToken=abc123; internal=true').exactly(5).times
156
195
  expect(cookie_response).to receive(:get_fields).with('set-cookie').exactly(5).times
157
196
  expect(basic_auth_http_conn).to receive(:request).exactly(5).times.with(request).and_return(cookie_response)
@@ -174,7 +213,8 @@ describe JIRA::HttpClient do
174
213
  expect(Net::HTTP::Get).to receive(:new).with('/foo', headers).and_return(http_request)
175
214
 
176
215
  expect(basic_auth_http_conn).to receive(:request).with(http_request).and_return(response)
177
- expect(http_request).to receive(:basic_auth).with(basic_client.options[:username], basic_client.options[:password]).and_return(http_request)
216
+ expect(http_request).to receive(:basic_auth).with(basic_client.options[:username],
217
+ basic_client.options[:password]).and_return(http_request)
178
218
  allow(basic_client).to receive(:basic_auth_http_conn).and_return(basic_auth_http_conn)
179
219
  basic_client.make_request(:get, '/foo', body, headers)
180
220
  end
@@ -187,7 +227,8 @@ describe JIRA::HttpClient do
187
227
  expect(Net::HTTP::Get).to receive(:new).with('/foo', headers).and_return(http_request)
188
228
 
189
229
  expect(basic_auth_http_conn).to receive(:request).with(http_request).and_return(response)
190
- expect(http_request).to receive(:basic_auth).with(basic_client.options[:username], basic_client.options[:password]).and_return(http_request)
230
+ expect(http_request).to receive(:basic_auth).with(basic_client.options[:username],
231
+ basic_client.options[:password]).and_return(http_request)
191
232
  allow(basic_client).to receive(:basic_auth_http_conn).and_return(basic_auth_http_conn)
192
233
  basic_client.make_request(:get, 'http://mydomain.com/foo', body, headers)
193
234
  end
@@ -254,19 +295,29 @@ describe JIRA::HttpClient do
254
295
  expect(proxy_configuration.proxy_pass).to be_nil
255
296
  end
256
297
 
257
- it 'sets up a proxied http connection when using proxy options' do
258
- uri = double
259
- host = double
260
- port = double
298
+ context 'client has proxy settings' do
299
+ subject(:proxy_conn) { proxy_client.basic_auth_http_conn }
300
+
301
+ let(:proxy_client) do
302
+ options_local = JIRA::Client::DEFAULT_OPTIONS.merge(JIRA::HttpClient::DEFAULT_OPTIONS).merge(
303
+ proxy_address: 'proxyAddress',
304
+ proxy_port: 42,
305
+ proxy_username: 'proxyUsername',
306
+ proxy_password: 'proxyPassword'
307
+ )
308
+ described_class.new(options_local)
309
+ end
261
310
 
262
- expect(uri).to receive(:host).and_return(host)
263
- expect(uri).to receive(:port).and_return(port)
311
+ describe 'HttpClient#basic_auth_http_conn' do
312
+ it 'creates a Net:HTTP instance for a basic auth client setting up a proxied http connection' do
313
+ expect(proxy_conn.class).to eq(Net::HTTP)
264
314
 
265
- proxy_configuration = proxy_client.http_conn(uri).class
266
- expect(proxy_configuration.proxy_address).to eq(proxy_client.options[:proxy_address])
267
- expect(proxy_configuration.proxy_port).to eq(proxy_client.options[:proxy_port])
268
- expect(proxy_configuration.proxy_user).to eq(proxy_client.options[:proxy_username])
269
- expect(proxy_configuration.proxy_pass).to eq(proxy_client.options[:proxy_password])
315
+ expect(proxy_conn.proxy_address).to eq(proxy_client.options[:proxy_address])
316
+ expect(proxy_conn.proxy_port).to eq(proxy_client.options[:proxy_port])
317
+ expect(proxy_conn.proxy_user).to eq(proxy_client.options[:proxy_username])
318
+ expect(proxy_conn.proxy_pass).to eq(proxy_client.options[:proxy_password])
319
+ end
320
+ end
270
321
  end
271
322
 
272
323
  it 'can use client certificates' do
@@ -285,6 +336,26 @@ describe JIRA::HttpClient do
285
336
  expect(basic_client_cert_client.http_conn(uri)).to eq(http_conn)
286
337
  end
287
338
 
339
+ it 'can use a certificate authority file' do
340
+ client = described_class.new(JIRA::Client::DEFAULT_OPTIONS.merge(ca_file: '/opt/custom.ca.pem'))
341
+ expect(client.http_conn(client.uri).ca_file).to eql('/opt/custom.ca.pem')
342
+ end
343
+
344
+ it 'allows overriding max_retries' do
345
+ http_conn = double
346
+ uri = double
347
+ host = double
348
+ port = double
349
+ expect(uri).to receive(:host).and_return(host)
350
+ expect(uri).to receive(:port).and_return(port)
351
+ expect(Net::HTTP).to receive(:new).with(host, port).and_return(http_conn)
352
+ expect(http_conn).to receive(:use_ssl=).with(basic_client.options[:use_ssl]).and_return(http_conn)
353
+ expect(http_conn).to receive(:verify_mode=).with(basic_client.options[:ssl_verify_mode]).and_return(http_conn)
354
+ expect(http_conn).to receive(:read_timeout=).with(basic_client.options[:read_timeout]).and_return(http_conn)
355
+ expect(http_conn).to receive(:max_retries=).with(basic_client_with_max_retries.options[:max_retries]).and_return(http_conn)
356
+ expect(basic_client_with_max_retries.http_conn(uri)).to eq(http_conn)
357
+ end
358
+
288
359
  it 'returns a http connection' do
289
360
  http_conn = double
290
361
  uri = double
@@ -302,7 +373,7 @@ describe JIRA::HttpClient do
302
373
  let(:data) { {} }
303
374
  let(:headers) { { 'X-Atlassian-Token' => 'no-check' } }
304
375
  let(:basic_auth_http_conn) { double }
305
- let(:request) { double('Http Request', path: path) }
376
+ let(:request) { double('Http Request', path:) }
306
377
  let(:response) { double('response') }
307
378
 
308
379
  before do
@@ -313,7 +384,8 @@ describe JIRA::HttpClient do
313
384
  end
314
385
 
315
386
  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)
387
+ expect(request).to receive(:basic_auth).with(basic_client.options[:username],
388
+ basic_client.options[:password]).and_return(request)
317
389
 
318
390
  subject
319
391
  end
@@ -1,6 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::HTTPError do
4
+ subject { described_class.new(response) }
5
+
4
6
  let(:response) do
5
7
  response = double('response')
6
8
  allow(response).to receive(:code).and_return(401)
@@ -8,8 +10,6 @@ describe JIRA::HTTPError do
8
10
  response
9
11
  end
10
12
 
11
- subject { described_class.new(response) }
12
-
13
13
  it 'takes the response object as an argument' do
14
14
  expect(subject.response).to eq(response)
15
15
  end
@@ -4,7 +4,7 @@ describe JIRA::OauthClient do
4
4
  let(:oauth_client) do
5
5
  options = { consumer_key: 'foo', consumer_secret: 'bar' }
6
6
  options = JIRA::Client::DEFAULT_OPTIONS.merge(options)
7
- JIRA::OauthClient.new(options)
7
+ described_class.new(options)
8
8
  end
9
9
 
10
10
  let(:response) do
@@ -35,6 +35,26 @@ describe JIRA::OauthClient do
35
35
  expect(oauth_client.get_request_token).to eq(request_token)
36
36
  end
37
37
 
38
+ it 'could pre-process the response body in a block' do
39
+ response = Net::HTTPSuccess.new(1.0, '200', 'OK')
40
+ allow_any_instance_of(OAuth::Consumer).to receive(:request).and_return(response)
41
+ allow(response).to receive(:body).and_return('&oauth_token=token&oauth_token_secret=secret&password=top_secret')
42
+
43
+ result = oauth_client.request_token do |response_body|
44
+ CGI.parse(response_body).each_with_object({}) do |(k, v), h|
45
+ next if k == 'password'
46
+
47
+ h[k.strip.to_sym] = v.first
48
+ end
49
+ end
50
+
51
+ expect(result).to be_an_instance_of(OAuth::RequestToken)
52
+ expect(result.consumer).to eql(oauth_client.consumer)
53
+ expect(result.params[:oauth_token]).to eql('token')
54
+ expect(result.params[:oauth_token_secret]).to eql('secret')
55
+ expect(result.params[:password]).to be_falsey
56
+ end
57
+
38
58
  it 'allows setting the request token' do
39
59
  token = double
40
60
  expect(OAuth::RequestToken).to receive(:new).with(oauth_client.consumer, 'foo', 'bar').and_return(token)
@@ -58,7 +78,7 @@ describe JIRA::OauthClient do
58
78
  request_token = OAuth::RequestToken.new(oauth_client.consumer)
59
79
  allow(oauth_client).to receive(:get_request_token).and_return(request_token)
60
80
  mock_access_token = double
61
- expect(request_token).to receive(:get_access_token).with(oauth_verifier: 'abc123').and_return(mock_access_token)
81
+ expect(request_token).to receive(:get_access_token).with({ oauth_verifier: 'abc123' }).and_return(mock_access_token)
62
82
  oauth_client.init_access_token(oauth_verifier: 'abc123')
63
83
  expect(oauth_client.access_token).to eq(mock_access_token)
64
84
  end
@@ -104,7 +124,6 @@ describe JIRA::OauthClient do
104
124
  it 'performs a request' do
105
125
  expect(access_token).to receive(:send).with(:get, '/foo', headers).and_return(response)
106
126
 
107
-
108
127
  oauth_client.request(:get, '/foo', body, headers)
109
128
  end
110
129
 
@@ -116,7 +135,8 @@ describe JIRA::OauthClient do
116
135
 
117
136
  it 'signs the access_token and performs the request' do
118
137
  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))
138
+ expect(oauth_client.consumer).to receive_message_chain(:http,
139
+ :request).with(an_instance_of(Net::HTTP::Post::Multipart))
120
140
 
121
141
  subject
122
142
  end
@@ -127,7 +147,7 @@ describe JIRA::OauthClient do
127
147
  let(:oauth__2legged_client) do
128
148
  options = { consumer_key: 'foo', consumer_secret: 'bar', auth_type: :oauth_2legged }
129
149
  options = JIRA::Client::DEFAULT_OPTIONS.merge(options)
130
- JIRA::OauthClient.new(options)
150
+ described_class.new(options)
131
151
  end
132
152
 
133
153
  it 'responds to the http methods adding oauth_token parameter' do
@@ -149,14 +169,16 @@ describe JIRA::OauthClient do
149
169
  mock_access_token = double
150
170
  allow(oauth__2legged_client).to receive(:access_token).and_return(mock_access_token)
151
171
  %i[delete get head].each do |method|
152
- expect(mock_access_token).to receive(method).with('/path?any_param=toto&oauth_token=', headers).and_return(response)
172
+ expect(mock_access_token).to receive(method).with('/path?any_param=toto&oauth_token=',
173
+ headers).and_return(response)
153
174
  oauth__2legged_client.make_request(method, '/path?any_param=toto', '', headers)
154
175
  end
155
176
  %i[post put].each do |method|
156
- expect(mock_access_token).to receive(method).with('/path?any_param=toto&oauth_token=', '', headers).and_return(response)
177
+ expect(mock_access_token).to receive(method).with('/path?any_param=toto&oauth_token=', '',
178
+ headers).and_return(response)
157
179
  oauth__2legged_client.make_request(method, '/path?any_param=toto', '', headers)
158
180
  end
159
181
  end
160
182
  end
161
183
  end
162
- end
184
+ end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::RequestClient do
4
- let(:request_client) { JIRA::RequestClient.new }
4
+ let(:request_client) { described_class.new }
5
5
 
6
6
  describe '#request' do
7
7
  subject(:request) { request_client.request(:get, '/foo', '', {}) }
@@ -15,7 +15,7 @@ describe JIRA::RequestClient do
15
15
  end
16
16
 
17
17
  it 'raises an exception' do
18
- expect{ subject }.to raise_exception(JIRA::HTTPError)
18
+ expect { subject }.to raise_exception(JIRA::HTTPError)
19
19
  end
20
20
  end
21
21
  end
@@ -34,8 +34,8 @@ describe JIRA::RequestClient do
34
34
  end
35
35
 
36
36
  it 'raises an exception' do
37
- expect{ subject }.to raise_exception(JIRA::HTTPError)
37
+ expect { subject }.to raise_exception(JIRA::HTTPError)
38
38
  end
39
39
  end
40
40
  end
41
- end
41
+ end
@@ -9,34 +9,34 @@ describe JIRA::Resource::Agile do
9
9
  let(:response) { double }
10
10
 
11
11
  describe '#all' do
12
- it 'should query url without parameters' do
12
+ it 'queries url without parameters' do
13
13
  expect(client).to receive(:get).with('/jira/rest/agile/1.0/board').and_return(response)
14
14
  expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
15
15
 
16
- JIRA::Resource::Agile.all(client)
16
+ described_class.all(client)
17
17
  end
18
18
  end
19
19
 
20
20
  describe '#get_backlog_issues' do
21
- it 'should query the url without parameters' do
21
+ it 'queries the url without parameters' do
22
22
  expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/backlog?maxResults=100').and_return(response)
23
23
  expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
24
24
 
25
- JIRA::Resource::Agile.get_backlog_issues(client, 1)
25
+ described_class.get_backlog_issues(client, 1)
26
26
  end
27
27
  end
28
28
 
29
29
  describe '#get_board_issues' do
30
- it 'should query correct url without parameters' do
30
+ it 'queries correct url without parameters' do
31
31
  expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/issue?').and_return(response)
32
32
  expect(response).to receive(:body).and_return(get_mock_response('board/1_issues.json'))
33
33
 
34
34
  expect(client).to receive(:get).with('/jira/rest/api/2/search?jql=id+IN%2810546%2C+10547%2C+10556%2C+10557%2C+10558%2C+10559%2C+10600%2C+10601%2C+10604%29').and_return(response)
35
35
  expect(response).to receive(:body).and_return(get_mock_response('board/1_issues.json'))
36
36
 
37
- issues = JIRA::Resource::Agile.get_board_issues(client, 1)
37
+ issues = described_class.get_board_issues(client, 1)
38
38
  expect(issues).to be_an(Array)
39
- expect(issues.size).to eql(9)
39
+ expect(issues.size).to be(9)
40
40
 
41
41
  issues.each do |issue|
42
42
  expect(issue.class).to eq(JIRA::Resource::Issue)
@@ -44,16 +44,16 @@ describe JIRA::Resource::Agile do
44
44
  end
45
45
  end
46
46
 
47
- it 'should query correct url with parameters' do
47
+ it 'queries correct url with parameters' do
48
48
  expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/issue?startAt=50').and_return(response)
49
49
  expect(response).to receive(:body).and_return(get_mock_response('board/1_issues.json'))
50
50
 
51
51
  expect(client).to receive(:get).with('/jira/rest/api/2/search?jql=id+IN%2810546%2C+10547%2C+10556%2C+10557%2C+10558%2C+10559%2C+10600%2C+10601%2C+10604%29').and_return(response)
52
52
  expect(response).to receive(:body).and_return(get_mock_response('board/1_issues.json'))
53
53
 
54
- issues = JIRA::Resource::Agile.get_board_issues(client, 1, startAt: 50)
54
+ issues = described_class.get_board_issues(client, 1, startAt: 50)
55
55
  expect(issues).to be_an(Array)
56
- expect(issues.size).to eql(9)
56
+ expect(issues.size).to be(9)
57
57
 
58
58
  issues.each do |issue|
59
59
  expect(issue.class).to eq(JIRA::Resource::Issue)
@@ -63,73 +63,73 @@ describe JIRA::Resource::Agile do
63
63
  end
64
64
 
65
65
  describe '#get_sprints' do
66
- it 'should query correct url without parameters' do
66
+ it 'queries correct url without parameters' do
67
67
  expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/sprint?maxResults=100').and_return(response)
68
68
  expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
69
69
 
70
- JIRA::Resource::Agile.get_sprints(client, 1)
70
+ described_class.get_sprints(client, 1)
71
71
  end
72
72
 
73
- it 'should query correct url with parameters' do
73
+ it 'queries correct url with parameters' do
74
74
  expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/sprint?startAt=50&maxResults=100').and_return(response)
75
75
  expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
76
76
 
77
- JIRA::Resource::Agile.get_sprints(client, 1, startAt: 50)
77
+ described_class.get_sprints(client, 1, startAt: 50)
78
78
  end
79
79
 
80
- it 'should work with pagination starting at 0' do
80
+ it 'works with pagination starting at 0' do
81
81
  expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/sprint?maxResults=1&startAt=0').and_return(response)
82
82
  expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
83
83
 
84
- JIRA::Resource::Agile.get_sprints(client, 1, maxResults: 1, startAt: 0)
84
+ described_class.get_sprints(client, 1, maxResults: 1, startAt: 0)
85
85
  end
86
86
 
87
- it 'should work with pagination not starting at 0' do
87
+ it 'works with pagination not starting at 0' do
88
88
  expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/sprint?maxResults=1&startAt=1').and_return(response)
89
89
  expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
90
90
 
91
- JIRA::Resource::Agile.get_sprints(client, 1, maxResults: 1, startAt: 1)
91
+ described_class.get_sprints(client, 1, maxResults: 1, startAt: 1)
92
92
  end
93
93
  end
94
94
 
95
95
  describe '#get_sprint_issues' do
96
- it 'should query correct url without parameters' do
96
+ it 'queries correct url without parameters' do
97
97
  expect(client).to receive(:get).with('/jira/rest/agile/1.0/sprint/1/issue?maxResults=100').and_return(response)
98
98
  expect(response).to receive(:body).and_return(get_mock_response('sprint/1_issues.json'))
99
99
 
100
- JIRA::Resource::Agile.get_sprint_issues(client, 1)
100
+ described_class.get_sprint_issues(client, 1)
101
101
  end
102
102
 
103
- it 'should query correct url with parameters' do
103
+ it 'queries correct url with parameters' do
104
104
  expect(client).to receive(:get).with('/jira/rest/agile/1.0/sprint/1/issue?startAt=50&maxResults=100').and_return(response)
105
105
  expect(response).to receive(:body).and_return(get_mock_response('sprint/1_issues.json'))
106
106
 
107
- JIRA::Resource::Agile.get_sprint_issues(client, 1, startAt: 50)
107
+ described_class.get_sprint_issues(client, 1, startAt: 50)
108
108
  end
109
109
  end
110
110
 
111
111
  describe '#get_projects_full' do
112
- it 'should query correct url without parameters' do
112
+ it 'queries correct url without parameters' do
113
113
  expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/project/full').and_return(response)
114
114
  expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
115
115
 
116
- JIRA::Resource::Agile.get_projects_full(client, 1)
116
+ described_class.get_projects_full(client, 1)
117
117
  end
118
118
  end
119
119
 
120
120
  describe '#get_projects' do
121
- it 'should query correct url without parameters' do
121
+ it 'queries correct url without parameters' do
122
122
  expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/project?maxResults=100').and_return(response)
123
123
  expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
124
124
 
125
- JIRA::Resource::Agile.get_projects(client, 1)
125
+ described_class.get_projects(client, 1)
126
126
  end
127
127
 
128
- it 'should query correct url with parameters' do
128
+ it 'queries correct url with parameters' do
129
129
  expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/project?startAt=50&maxResults=100').and_return(response)
130
130
  expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
131
131
 
132
- JIRA::Resource::Agile.get_projects(client, 1, startAt: 50)
132
+ described_class.get_projects(client, 1, startAt: 50)
133
133
  end
134
134
  end
135
135
  end