jira-ruby 2.1.0 → 2.3.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
2
  SHA256:
3
- metadata.gz: 2fea6e6a55a6679e8dab6437b19ccb62d29f8d31ec4db8b36c449ce3cae78f44
4
- data.tar.gz: e4f8e7e6c1be0344db51d6a516c3da9db55343f93a49cb08072d0dbf5c462f16
3
+ metadata.gz: 113ad755633d6eb87e63d7a97d3228f6649828547c01dee1ae1900ef0d575e2d
4
+ data.tar.gz: d59620f52976814ee7db58df10213bdb512f042a8b8214789ed07288f2899b65
5
5
  SHA512:
6
- metadata.gz: 934781eb8ab9ec5bc4da7ad9b1c048dc52adaffd17c389046c10f1078e93495f248d4af219dd10fc105a87e8ef6d58c99ada61db40c86238ee7f844ab632c831
7
- data.tar.gz: 7ebaeb51adb377be540de240939188b3e88b85554958f3bd0cd187346778a3b45c0ee9cc70c23d4e5763f16fc2e96b36032a32253845c8a98d5c1c3de0bc2e7d
6
+ metadata.gz: e523698732b5cef8a220259ccf5c42c568ac7eea435ee2ed2f2018cdd25959597d23337a67fac037e00be85a8838d9d32a2c79a156da008380699d2c9529cb03
7
+ data.tar.gz: cefe63455cb070951d73420dc1144b0c0a4651836427f507d218d3eb0780936e6a740842f6f2df8f68b14be8034bb196b4f5069d21ac0c3cd9e2a4292e43b456
data/README.md CHANGED
@@ -99,7 +99,7 @@ defaults to HTTP Basic Auth.
99
99
 
100
100
  Jira supports cookie based authentication whereby user credentials are passed
101
101
  to JIRA via a JIRA REST API call. This call returns a session cookie which must
102
- then be sent to all following JIRA REST API calls.
102
+ then be sent to all following JIRA REST API calls.
103
103
 
104
104
  To enable cookie based authentication, set `:auth_type` to `:cookie`,
105
105
  set `:use_cookies` to `true` and set `:username` and `:password` accordingly.
@@ -114,7 +114,7 @@ options = {
114
114
  :context_path => '',
115
115
  :auth_type => :cookie, # Set cookie based authentication
116
116
  :use_cookies => true, # Send cookies with each request
117
- :additional_cookies => ['AUTH=vV7uzixt0SScJKg7'] # Optional cookies to send
117
+ :additional_cookies => ['AUTH=vV7uzixt0SScJKg7'] # Optional cookies to send
118
118
  # with each request
119
119
  }
120
120
 
@@ -134,15 +134,40 @@ cookie to add to the request.
134
134
 
135
135
  Some authentication schemes that require additional cookies ignore the username
136
136
  and password sent in the JIRA REST API call. For those use cases, `:username`
137
- and `:password` may be omitted from `options`.
137
+ and `:password` may be omitted from `options`.
138
138
 
139
+ ## Configuring JIRA to use Personal Access Tokens Auth
140
+ If your JIRA system is configured to support Personal Access Token authorization, minor modifications are needed in how credentials are communicated to the server. Specifically, the paremeters `:username` and `:password` are not needed. Also, the parameter `:default_headers` is needed to contain the api_token, which can be obtained following the official documentation from [Atlassian](https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html). Please note that the Personal Access Token can only be used as it is. If it is encoded (with base64 or any other encoding method) then the token will not work correctly and authentication will fail.
141
+
142
+ ```ruby
143
+ require 'jira-ruby'
144
+
145
+ # NOTE: the token should not be encoded
146
+ api_token = API_TOKEN_OBTAINED_FROM_JIRA_UI
147
+
148
+ options = {
149
+ :site => 'http://mydomain.atlassian.net:443/',
150
+ :context_path => '',
151
+ :username => '<the email you sign-in to Jira>',
152
+ :password => api_token,
153
+ :auth_type => :basic
154
+ }
155
+
156
+ client = JIRA::Client.new(options)
157
+
158
+ project = client.Project.find('SAMPLEPROJECT')
159
+
160
+ project.issues.each do |issue|
161
+ puts "#{issue.id} - #{issue.summary}"
162
+ end
163
+ ```
139
164
  ## Using the API Gem in a command line application
140
165
 
141
166
  Using HTTP Basic Authentication, configure and connect a client to your instance
142
167
  of JIRA.
143
168
 
144
169
  Note: If your Jira install is hosted on [atlassian.net](atlassian.net), it will have no context
145
- path by default. If you're having issues connecting, try setting context_path
170
+ path by default. If you're having issues connecting, try setting context_path
146
171
  to an empty string in the options hash.
147
172
 
148
173
  ```ruby
data/Rakefile CHANGED
@@ -14,13 +14,13 @@ desc 'Prepare and run rspec tests'
14
14
  task :prepare do
15
15
  rsa_key = File.expand_path('rsakey.pem')
16
16
  unless File.exist?(rsa_key)
17
- raise 'rsakey.pem does not exist, tests will fail. Run `rake jira:generate_public_cert` first'
17
+ Rake::Task['jira:generate_public_cert'].invoke
18
18
  end
19
19
  end
20
20
 
21
21
  desc 'Run RSpec tests'
22
22
  # RSpec::Core::RakeTask.new(:spec)
23
- RSpec::Core::RakeTask.new(:spec) do |task|
23
+ RSpec::Core::RakeTask.new(:spec, [] => [:prepare]) do |task|
24
24
  task.rspec_opts = ['--color', '--format', 'doc']
25
25
  end
26
26
 
data/example.rb CHANGED
@@ -166,6 +166,14 @@ client.Issue.jql(a_normal_jql_search, max_results: 500)
166
166
  # # --------------------------
167
167
  # issue.comments.first.save({"body" => "an updated comment frome example.rb"})
168
168
 
169
+
170
+ # # Add attachment to Issue
171
+ # # ------------------------
172
+ # issue = client.Issue.find('PROJ-1')
173
+ # attachment = issue.attachments.build
174
+ # attachment.save('file': '/path/to/file')
175
+ #
176
+
169
177
  # List all available link types
170
178
  # ------------------------------
171
179
  pp client.Issuelinktype.all
data/lib/jira/client.rb CHANGED
@@ -6,7 +6,7 @@ module JIRA
6
6
  # This class is the main access point for all JIRA::Resource instances.
7
7
  #
8
8
  # The client must be initialized with an options hash containing
9
- # configuration options. The available options are:
9
+ # configuration options. The available options are:
10
10
  #
11
11
  # :site => 'http://localhost:2990',
12
12
  # :context_path => '/jira',
@@ -14,6 +14,7 @@ module JIRA
14
14
  # :request_token_path => "/plugins/servlet/oauth/request-token",
15
15
  # :authorize_path => "/plugins/servlet/oauth/authorize",
16
16
  # :access_token_path => "/plugins/servlet/oauth/access-token",
17
+ # :private_key => nil,
17
18
  # :private_key_file => "rsakey.pem",
18
19
  # :rest_base_path => "/rest/api/2",
19
20
  # :consumer_key => nil,
@@ -28,11 +29,18 @@ module JIRA
28
29
  # :proxy_port => nil,
29
30
  # :proxy_username => nil,
30
31
  # :proxy_password => nil,
32
+ # :use_cookies => nil,
31
33
  # :additional_cookies => nil,
32
34
  # :default_headers => {},
33
35
  # :use_client_cert => false,
36
+ # :read_timeout => nil,
34
37
  # :http_debug => false,
35
- # :shared_secret => nil
38
+ # :shared_secret => nil,
39
+ # :cert_path => nil,
40
+ # :key_path => nil,
41
+ # :ssl_client_cert => nil,
42
+ # :ssl_client_key => nil
43
+ # :ca_file => nil
36
44
  #
37
45
  # See the JIRA::Base class methods for all of the available methods on these accessor
38
46
  # objects.
@@ -58,6 +66,7 @@ module JIRA
58
66
  :request_token_path,
59
67
  :authorize_path,
60
68
  :access_token_path,
69
+ :private_key,
61
70
  :private_key_file,
62
71
  :rest_base_path,
63
72
  :consumer_key,
@@ -72,13 +81,19 @@ module JIRA
72
81
  :proxy_port,
73
82
  :proxy_username,
74
83
  :proxy_password,
84
+ :use_cookies,
75
85
  :additional_cookies,
76
86
  :default_headers,
77
87
  :use_client_cert,
88
+ :read_timeout,
78
89
  :http_debug,
79
90
  :issuer,
80
91
  :base_url,
81
- :shared_secret
92
+ :shared_secret,
93
+ :cert_path,
94
+ :key_path,
95
+ :ssl_client_cert,
96
+ :ssl_client_key
82
97
  ].freeze
83
98
 
84
99
  DEFAULT_OPTIONS = {
@@ -102,10 +117,11 @@ module JIRA
102
117
  raise ArgumentError, "Unknown option(s) given: #{unknown_options}" unless unknown_options.empty?
103
118
 
104
119
  if options[:use_client_cert]
105
- raise ArgumentError, 'Options: :cert_path must be set when :use_client_cert is true' unless @options[:cert_path]
106
- raise ArgumentError, 'Options: :key_path must be set when :use_client_cert is true' unless @options[:key_path]
107
- @options[:cert] = OpenSSL::X509::Certificate.new(File.read(@options[:cert_path]))
108
- @options[:key] = OpenSSL::PKey::RSA.new(File.read(@options[:key_path]))
120
+ @options[:ssl_client_cert] = OpenSSL::X509::Certificate.new(File.read(@options[:cert_path])) if @options[:cert_path]
121
+ @options[:ssl_client_key] = OpenSSL::PKey::RSA.new(File.read(@options[:key_path])) if @options[:key_path]
122
+
123
+ raise ArgumentError, 'Options: :cert_path or :ssl_client_cert must be set when :use_client_cert is true' unless @options[:ssl_client_cert]
124
+ raise ArgumentError, 'Options: :key_path or :ssl_client_key must be set when :use_client_cert is true' unless @options[:ssl_client_key]
109
125
  end
110
126
 
111
127
  case options[:auth_type]
@@ -242,6 +258,10 @@ module JIRA
242
258
  JIRA::Resource::IssuelinktypeFactory.new(self)
243
259
  end
244
260
 
261
+ def IssuePickerSuggestions
262
+ JIRA::Resource::IssuePickerSuggestionsFactory.new(self)
263
+ end
264
+
245
265
  def Remotelink
246
266
  JIRA::Resource::RemotelinkFactory.new(self)
247
267
  end
@@ -286,6 +306,11 @@ module JIRA
286
306
  @request_client.request(http_method, path, body, headers)
287
307
  end
288
308
 
309
+ # Stops sensitive client information from being displayed in logs
310
+ def inspect
311
+ "#<JIRA::Client:#{object_id}>"
312
+ end
313
+
289
314
  protected
290
315
 
291
316
  def merge_default_headers(headers)
@@ -53,12 +53,13 @@ module JIRA
53
53
  http_conn = http_class.new(uri.host, uri.port)
54
54
  http_conn.use_ssl = @options[:use_ssl]
55
55
  if @options[:use_client_cert]
56
- http_conn.cert = @options[:cert]
57
- http_conn.key = @options[:key]
56
+ http_conn.cert = @options[:ssl_client_cert]
57
+ http_conn.key = @options[:ssl_client_key]
58
58
  end
59
59
  http_conn.verify_mode = @options[:ssl_verify_mode]
60
60
  http_conn.ssl_version = @options[:ssl_version] if @options[:ssl_version]
61
61
  http_conn.read_timeout = @options[:read_timeout]
62
+ http_conn.ca_file = @options[:ca_file] if @options[:ca_file]
62
63
  http_conn
63
64
  end
64
65
 
@@ -38,13 +38,15 @@ module JIRA
38
38
  @options[:request_token_path] = @options[:context_path] + @options[:request_token_path]
39
39
  @options[:authorize_path] = @options[:context_path] + @options[:authorize_path]
40
40
  @options[:access_token_path] = @options[:context_path] + @options[:access_token_path]
41
+ # proxy_address does not exist in oauth's gem context but proxy does
42
+ @options[:proxy] = @options[:proxy_address] if @options[:proxy_address]
41
43
  OAuth::Consumer.new(@options[:consumer_key], @options[:consumer_secret], @options)
42
44
  end
43
45
 
44
46
  # Returns the current request token if it is set, else it creates
45
47
  # and sets a new token.
46
48
  def request_token(options = {}, *arguments, &block)
47
- @request_token ||= get_request_token(options, *arguments, block)
49
+ @request_token ||= get_request_token(options, *arguments, &block)
48
50
  end
49
51
 
50
52
  # Sets the request token from a given token and secret.
@@ -0,0 +1,24 @@
1
+ module JIRA
2
+ module Resource
3
+ class IssuePickerSuggestionsFactory < JIRA::BaseFactory # :nodoc:
4
+ end
5
+
6
+ class IssuePickerSuggestions < JIRA::Base
7
+ has_many :sections, class: JIRA::Resource::IssuePickerSuggestionsIssue
8
+
9
+ def self.all(client, query = '', options = { current_jql: nil, current_issue_key: nil, current_project_id: nil, show_sub_tasks: nil, show_sub_tasks_parent: nil })
10
+ url = client.options[:rest_base_path] + "/issue/picker?query=#{CGI.escape(query)}"
11
+
12
+ url << "&currentJQL=#{CGI.escape(options[:current_jql])}" if options[:current_jql]
13
+ url << "&currentIssueKey=#{CGI.escape(options[:current_issue_key])}" if options[:current_issue_key]
14
+ url << "&currentProjectId=#{CGI.escape(options[:current_project_id])}" if options[:current_project_id]
15
+ url << "&showSubTasks=#{options[:show_sub_tasks]}" if options[:show_sub_tasks]
16
+ url << "&showSubTaskParent=#{options[:show_sub_task_parent]}" if options[:show_sub_task_parent]
17
+
18
+ response = client.get(url)
19
+ json = parse_json(response.body)
20
+ client.IssuePickerSuggestions.build(json)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ module JIRA
2
+ module Resource
3
+ class IssuePickerSuggestionsIssueFactory < JIRA::BaseFactory # :nodoc:
4
+ end
5
+
6
+ class IssuePickerSuggestionsIssue < JIRA::Base
7
+ has_many :issues, class: JIRA::Resource::SuggestedIssue
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ module JIRA
2
+ module Resource
3
+ class SuggestedIssueFactory < JIRA::BaseFactory # :nodoc:
4
+ end
5
+
6
+ class SuggestedIssue < JIRA::Base
7
+ end
8
+ end
9
+ end
@@ -18,7 +18,7 @@ module JIRA
18
18
 
19
19
  # Cannot retrieve more than 1,000 users through the api, please see: https://jira.atlassian.com/browse/JRASERVER-65089
20
20
  def self.all(client)
21
- response = client.get("/rest/api/2/user/search?username=_&maxResults=#{MAX_RESULTS}")
21
+ response = client.get("/rest/api/2/users/search?username=_&maxResults=#{MAX_RESULTS}")
22
22
  all_users = JSON.parse(response.body)
23
23
 
24
24
  all_users.flatten.uniq.map do |user|
data/lib/jira/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module JIRA
2
- VERSION = '2.1.0'.freeze
2
+ VERSION = '2.3.0'.freeze
3
3
  end
data/lib/jira-ruby.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  $LOAD_PATH << __dir__
2
2
 
3
+ require 'active_support'
3
4
  require 'active_support/inflector'
4
5
  ActiveSupport::Inflector.inflections do |inflector|
5
6
  inflector.singular /status$/, 'status'
@@ -25,6 +26,9 @@ require 'jira/resource/worklog'
25
26
  require 'jira/resource/applinks'
26
27
  require 'jira/resource/issuelinktype'
27
28
  require 'jira/resource/issuelink'
29
+ require 'jira/resource/suggested_issue'
30
+ require 'jira/resource/issue_picker_suggestions_issue'
31
+ require 'jira/resource/issue_picker_suggestions'
28
32
  require 'jira/resource/remotelink'
29
33
  require 'jira/resource/sprint'
30
34
  require 'jira/resource/sprint_report'
@@ -21,18 +21,18 @@ describe JIRA::Resource::User do
21
21
  describe '#all' do
22
22
  let(:client) do
23
23
  client = double(options: { rest_base_path: '/jira/rest/api/2' })
24
- allow(client).to receive(:get).with('/rest/api/2/user/search?username=_&maxResults=1000').and_return(JIRA::Resource::UserFactory.new(client))
24
+ allow(client).to receive(:get).with('/rest/api/2/users/search?username=_&maxResults=1000').and_return(JIRA::Resource::UserFactory.new(client))
25
25
  client
26
26
  end
27
27
 
28
28
  before do
29
29
  allow(client).to receive(:get)
30
- .with('/rest/api/2/user/search?username=_&maxResults=1000') { OpenStruct.new(body: '["User1"]') }
30
+ .with('/rest/api/2/users/search?username=_&maxResults=1000') { OpenStruct.new(body: '["User1"]') }
31
31
  allow(client).to receive_message_chain(:User, :build).with('users') { [] }
32
32
  end
33
33
 
34
34
  it 'gets users with maxResults of 1000' do
35
- expect(client).to receive(:get).with('/rest/api/2/user/search?username=_&maxResults=1000')
35
+ expect(client).to receive(:get).with('/rest/api/2/users/search?username=_&maxResults=1000')
36
36
  expect(client).to receive_message_chain(:User, :build).with('User1')
37
37
  JIRA::Resource::User.all(client)
38
38
  end
@@ -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
@@ -280,11 +280,16 @@ 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[:cert])
284
- expect(http_conn).to receive(:key=).with(basic_client_cert_client.options[:key])
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
 
288
+ it 'can use a certificate authority file' do
289
+ client = JIRA::HttpClient.new(JIRA::Client::DEFAULT_OPTIONS.merge(ca_file: '/opt/custom.ca.pem'))
290
+ expect(client.http_conn(client.uri).ca_file).to eql('/opt/custom.ca.pem')
291
+ end
292
+
288
293
  it 'returns a http connection' do
289
294
  http_conn = double
290
295
  uri = double
@@ -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
@@ -159,4 +179,4 @@ describe JIRA::OauthClient do
159
179
  end
160
180
  end
161
181
  end
162
- end
182
+ 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&currentJQL=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&currentIssueKey=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&currentProjectId=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
@@ -47,7 +47,7 @@ describe JIRA::Resource::Issue do
47
47
  .and_return(empty_response)
48
48
 
49
49
  expect(client).to receive(:Issue).and_return(issue)
50
- expect(issue).to receive(:build).with('id' => '1', 'summary' => 'Bugs Everywhere')
50
+ expect(issue).to receive(:build).with({ 'id' => '1', 'summary' => 'Bugs Everywhere' })
51
51
 
52
52
  issues = JIRA::Resource::Issue.all(client)
53
53
  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
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jira-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SUMO Heavy Industries
8
8
  - test IO
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-07-03 00:00:00.000000000 Z
12
+ date: 2023-01-23 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,44 +171,44 @@ 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
- email:
211
+ email:
212
212
  executables: []
213
213
  extensions: []
214
214
  extra_rdoc_files: []
@@ -245,6 +245,8 @@ files:
245
245
  - lib/jira/resource/field.rb
246
246
  - lib/jira/resource/filter.rb
247
247
  - lib/jira/resource/issue.rb
248
+ - lib/jira/resource/issue_picker_suggestions.rb
249
+ - lib/jira/resource/issue_picker_suggestions_issue.rb
248
250
  - lib/jira/resource/issuelink.rb
249
251
  - lib/jira/resource/issuelinktype.rb
250
252
  - lib/jira/resource/issuetype.rb
@@ -257,6 +259,7 @@ files:
257
259
  - lib/jira/resource/sprint.rb
258
260
  - lib/jira/resource/sprint_report.rb
259
261
  - lib/jira/resource/status.rb
262
+ - lib/jira/resource/suggested_issue.rb
260
263
  - lib/jira/resource/transition.rb
261
264
  - lib/jira/resource/user.rb
262
265
  - lib/jira/resource/version.rb
@@ -299,8 +302,10 @@ files:
299
302
  - spec/jira/resource/createmeta_spec.rb
300
303
  - spec/jira/resource/field_spec.rb
301
304
  - spec/jira/resource/filter_spec.rb
305
+ - spec/jira/resource/issue_picker_suggestions_spec.rb
302
306
  - spec/jira/resource/issue_spec.rb
303
307
  - spec/jira/resource/issuelink_spec.rb
308
+ - spec/jira/resource/jira_picker_suggestions_issue_spec.rb
304
309
  - spec/jira/resource/project_factory_spec.rb
305
310
  - spec/jira/resource/project_spec.rb
306
311
  - spec/jira/resource/sprint_spec.rb
@@ -370,7 +375,7 @@ licenses:
370
375
  - MIT
371
376
  metadata:
372
377
  source_code_uri: https://github.com/sumoheavy/jira-ruby
373
- post_install_message:
378
+ post_install_message:
374
379
  rdoc_options: []
375
380
  require_paths:
376
381
  - lib
@@ -385,8 +390,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
385
390
  - !ruby/object:Gem::Version
386
391
  version: '0'
387
392
  requirements: []
388
- rubygems_version: 3.0.3
389
- signing_key:
393
+ rubygems_version: 3.3.7
394
+ signing_key:
390
395
  specification_version: 4
391
396
  summary: Ruby Gem for use with the Atlassian JIRA REST API
392
397
  test_files:
@@ -423,8 +428,10 @@ test_files:
423
428
  - spec/jira/resource/createmeta_spec.rb
424
429
  - spec/jira/resource/field_spec.rb
425
430
  - spec/jira/resource/filter_spec.rb
431
+ - spec/jira/resource/issue_picker_suggestions_spec.rb
426
432
  - spec/jira/resource/issue_spec.rb
427
433
  - spec/jira/resource/issuelink_spec.rb
434
+ - spec/jira/resource/jira_picker_suggestions_issue_spec.rb
428
435
  - spec/jira/resource/project_factory_spec.rb
429
436
  - spec/jira/resource/project_spec.rb
430
437
  - spec/jira/resource/sprint_spec.rb