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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5226fc516e3462a036601589022516b7b81d341e
4
- data.tar.gz: 3383609edaa34f0c8b78ac7002e21d051a02fbea
2
+ SHA256:
3
+ metadata.gz: 2fea6e6a55a6679e8dab6437b19ccb62d29f8d31ec4db8b36c449ce3cae78f44
4
+ data.tar.gz: e4f8e7e6c1be0344db51d6a516c3da9db55343f93a49cb08072d0dbf5c462f16
5
5
  SHA512:
6
- metadata.gz: d94d3e49e1bdb3abe978049db45eb5a1ed4698822900b3df3fe3f6660cdfb739968af5366f2f359006a39af6fbddc926bd670126ce9daf3de0ef95d138d7ffb3
7
- data.tar.gz: 9b53adb2af3746bd00703afc0afa33aa825003261b4afa1328a99ba54183bfb43e865a568c7dbfb8d2b38fd6c8ae5f75f05bf8bf6f59e4bf1fc864378e370ab7
6
+ metadata.gz: 934781eb8ab9ec5bc4da7ad9b1c048dc52adaffd17c389046c10f1078e93495f248d4af219dd10fc105a87e8ef6d58c99ada61db40c86238ee7f844ab632c831
7
+ data.tar.gz: 7ebaeb51adb377be540de240939188b3e88b85554958f3bd0cd187346778a3b45c0ee9cc70c23d4e5763f16fc2e96b36032a32253845c8a98d5c1c3de0bc2e7d
data/.gitignore CHANGED
@@ -9,3 +9,5 @@ pkg/*
9
9
  .DS_STORE
10
10
  doc
11
11
  .ruby-version
12
+
13
+ .rakeTasks
@@ -3,7 +3,7 @@ rvm:
3
3
  - 2.4
4
4
  - 2.5
5
5
  - 2.6
6
- - ruby-head
6
+ - 2.7
7
7
  before_script:
8
8
  - rake jira:generate_public_cert
9
9
  script: bundle exec rake spec
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",
@@ -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)
@@ -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]
@@ -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("#{client.options[:site]}/rest/agile/1.0/sprint/#{key}")
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(client.options[:site] + "/rest/agile/1.0/sprint/#{id}/issue", request_body)
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 = client.options[:site] + '/rest/greenhopper/1.0/rapid/charts/sprintreport?rapidViewId=' +
51
- rapidview_id.to_s + '&sprintId=' + id.to_s
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, agile_url)
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, agile_url)
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 agile_url
97
- "#{client.options[:site]}/rest/agile/1.0/sprint/#{id}"
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
@@ -1,3 +1,3 @@
1
1
  module JIRA
2
- VERSION = '2.0.0'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  end
@@ -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'
@@ -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
- describe 'peristence' do
5
- let(:sprint) { described_class.new(client) }
6
- let(:client) { double('Client', options: { site: 'https://foo.bar.com' }) }
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, agile_sprint_url)
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, agile_sprint_url)
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, agile_sprint_url)
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, agile_sprint_url)
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, agile_sprint_url)
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, agile_sprint_url)
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.0.0
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-16 00:00:00.000000000 Z
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
- rubyforge_project:
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