jira-ruby 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/.travis.yml +1 -1
- data/README.md +3 -3
- data/lib/jira/base.rb +1 -1
- data/lib/jira/client.rb +37 -1
- data/lib/jira/resource/sprint.rb +12 -8
- data/lib/jira/version.rb +1 -1
- data/spec/jira/base_spec.rb +12 -0
- data/spec/jira/client_spec.rb +9 -0
- data/spec/jira/resource/sprint_spec.rb +23 -11
- metadata +27 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2fea6e6a55a6679e8dab6437b19ccb62d29f8d31ec4db8b36c449ce3cae78f44
|
4
|
+
data.tar.gz: e4f8e7e6c1be0344db51d6a516c3da9db55343f93a49cb08072d0dbf5c462f16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 934781eb8ab9ec5bc4da7ad9b1c048dc52adaffd17c389046c10f1078e93495f248d4af219dd10fc105a87e8ef6d58c99ada61db40c86238ee7f844ab632c831
|
7
|
+
data.tar.gz: 7ebaeb51adb377be540de240939188b3e88b85554958f3bd0cd187346778a3b45c0ee9cc70c23d4e5763f16fc2e96b36032a32253845c8a98d5c1c3de0bc2e7d
|
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/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
@@ -29,7 +29,10 @@ module JIRA
|
|
29
29
|
# :proxy_username => nil,
|
30
30
|
# :proxy_password => nil,
|
31
31
|
# :additional_cookies => nil,
|
32
|
-
# :default_headers => {}
|
32
|
+
# :default_headers => {},
|
33
|
+
# :use_client_cert => false,
|
34
|
+
# :http_debug => false,
|
35
|
+
# :shared_secret => nil
|
33
36
|
#
|
34
37
|
# See the JIRA::Base class methods for all of the available methods on these accessor
|
35
38
|
# objects.
|
@@ -48,6 +51,36 @@ module JIRA
|
|
48
51
|
|
49
52
|
def_delegators :@request_client, :init_access_token, :set_access_token, :set_request_token, :request_token, :access_token, :authenticated?
|
50
53
|
|
54
|
+
DEFINED_OPTIONS = [
|
55
|
+
:site,
|
56
|
+
:context_path,
|
57
|
+
:signature_method,
|
58
|
+
:request_token_path,
|
59
|
+
:authorize_path,
|
60
|
+
:access_token_path,
|
61
|
+
:private_key_file,
|
62
|
+
:rest_base_path,
|
63
|
+
:consumer_key,
|
64
|
+
:consumer_secret,
|
65
|
+
:ssl_verify_mode,
|
66
|
+
:ssl_version,
|
67
|
+
:use_ssl,
|
68
|
+
:username,
|
69
|
+
:password,
|
70
|
+
:auth_type,
|
71
|
+
:proxy_address,
|
72
|
+
:proxy_port,
|
73
|
+
:proxy_username,
|
74
|
+
:proxy_password,
|
75
|
+
:additional_cookies,
|
76
|
+
:default_headers,
|
77
|
+
:use_client_cert,
|
78
|
+
:http_debug,
|
79
|
+
:issuer,
|
80
|
+
:base_url,
|
81
|
+
:shared_secret
|
82
|
+
].freeze
|
83
|
+
|
51
84
|
DEFAULT_OPTIONS = {
|
52
85
|
site: 'http://localhost:2990',
|
53
86
|
context_path: '/jira',
|
@@ -65,6 +98,9 @@ module JIRA
|
|
65
98
|
@options = options
|
66
99
|
@options[:rest_base_path] = @options[:context_path] + @options[:rest_base_path]
|
67
100
|
|
101
|
+
unknown_options = options.keys.reject { |o| DEFINED_OPTIONS.include?(o) }
|
102
|
+
raise ArgumentError, "Unknown option(s) given: #{unknown_options}" unless unknown_options.empty?
|
103
|
+
|
68
104
|
if options[:use_client_cert]
|
69
105
|
raise ArgumentError, 'Options: :cert_path must be set when :use_client_cert is true' unless @options[:cert_path]
|
70
106
|
raise ArgumentError, 'Options: :key_path must be set when :use_client_cert is true' unless @options[:key_path]
|
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/version.rb
CHANGED
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
@@ -266,4 +266,13 @@ describe JIRA::Client do
|
|
266
266
|
|
267
267
|
include_examples 'OAuth Common Tests'
|
268
268
|
end
|
269
|
+
|
270
|
+
context 'with unknown options' do
|
271
|
+
let(:options) { { 'username' => 'foo', 'password' => 'bar', auth_type: :basic } }
|
272
|
+
subject { JIRA::Client.new(options) }
|
273
|
+
|
274
|
+
it 'raises an ArgumentError' do
|
275
|
+
expect { subject }.to raise_exception(ArgumentError, 'Unknown option(s) given: ["username", "password"]')
|
276
|
+
end
|
277
|
+
end
|
269
278
|
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
|
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: 2.
|
4
|
+
version: 2.1.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-07-03 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'
|
63
60
|
- - ">="
|
64
61
|
- !ruby/object:Gem::Version
|
65
62
|
version: 0.5.0
|
63
|
+
- - "~>"
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0.5'
|
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'
|
73
70
|
- - ">="
|
74
71
|
- !ruby/object:Gem::Version
|
75
72
|
version: 0.5.0
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.5'
|
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'
|
83
80
|
- - ">="
|
84
81
|
- !ruby/object:Gem::Version
|
85
82
|
version: 2.13.0
|
83
|
+
- - "~>"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '2.13'
|
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'
|
93
90
|
- - ">="
|
94
91
|
- !ruby/object:Gem::Version
|
95
92
|
version: 2.13.0
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '2.13'
|
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'
|
177
174
|
- - ">="
|
178
175
|
- !ruby/object:Gem::Version
|
179
176
|
version: 3.0.0
|
177
|
+
- - "~>"
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '3.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'
|
187
184
|
- - ">="
|
188
185
|
- !ruby/object:Gem::Version
|
189
186
|
version: 3.0.0
|
187
|
+
- - "~>"
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '3.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'
|
197
194
|
- - ">="
|
198
195
|
- !ruby/object:Gem::Version
|
199
196
|
version: 1.18.0
|
197
|
+
- - "~>"
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: '1.18'
|
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'
|
207
204
|
- - ">="
|
208
205
|
- !ruby/object:Gem::Version
|
209
206
|
version: 1.18.0
|
207
|
+
- - "~>"
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '1.18'
|
210
210
|
description: API for JIRA
|
211
211
|
email:
|
212
212
|
executables: []
|
@@ -385,8 +385,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
385
385
|
- !ruby/object:Gem::Version
|
386
386
|
version: '0'
|
387
387
|
requirements: []
|
388
|
-
|
389
|
-
rubygems_version: 2.5.1
|
388
|
+
rubygems_version: 3.0.3
|
390
389
|
signing_key:
|
391
390
|
specification_version: 4
|
392
391
|
summary: Ruby Gem for use with the Atlassian JIRA REST API
|