jira-ruby 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/Gemfile +7 -1
- data/Guardfile +1 -1
- data/Rakefile +4 -5
- data/http-basic-example.rb +13 -12
- data/jira-ruby.gemspec +9 -10
- data/lib/jira-ruby.rb +5 -2
- data/lib/jira/base.rb +49 -48
- data/lib/jira/base_factory.rb +1 -4
- data/lib/jira/client.rb +29 -20
- data/lib/jira/has_many_proxy.rb +0 -1
- data/lib/jira/http_client.rb +9 -10
- data/lib/jira/http_error.rb +3 -5
- data/lib/jira/oauth_client.rb +19 -20
- data/lib/jira/request_client.rb +3 -4
- data/lib/jira/resource/agile.rb +10 -8
- data/lib/jira/resource/applinks.rb +5 -8
- data/lib/jira/resource/attachment.rb +1 -2
- data/lib/jira/resource/board.rb +84 -0
- data/lib/jira/resource/comment.rb +0 -2
- data/lib/jira/resource/component.rb +1 -3
- data/lib/jira/resource/createmeta.rb +12 -14
- data/lib/jira/resource/field.rb +22 -22
- data/lib/jira/resource/filter.rb +2 -2
- data/lib/jira/resource/issue.rb +41 -39
- data/lib/jira/resource/issuelink.rb +3 -5
- data/lib/jira/resource/issuelinktype.rb +0 -1
- data/lib/jira/resource/issuetype.rb +1 -3
- data/lib/jira/resource/priority.rb +1 -3
- data/lib/jira/resource/project.rb +5 -7
- data/lib/jira/resource/rapidview.rb +28 -7
- data/lib/jira/resource/remotelink.rb +1 -4
- data/lib/jira/resource/resolution.rb +2 -4
- data/lib/jira/resource/serverinfo.rb +1 -2
- data/lib/jira/resource/sprint.rb +82 -18
- data/lib/jira/resource/sprint_report.rb +8 -0
- data/lib/jira/resource/status.rb +1 -3
- data/lib/jira/resource/transition.rb +2 -6
- data/lib/jira/resource/user.rb +12 -2
- data/lib/jira/resource/version.rb +1 -3
- data/lib/jira/resource/watcher.rb +1 -5
- data/lib/jira/resource/webhook.rb +3 -6
- data/lib/jira/resource/worklog.rb +3 -5
- data/lib/jira/version.rb +1 -1
- data/lib/tasks/generate.rake +4 -4
- data/spec/integration/attachment_spec.rb +15 -16
- data/spec/integration/comment_spec.rb +31 -34
- data/spec/integration/component_spec.rb +21 -24
- data/spec/integration/field_spec.rb +15 -18
- data/spec/integration/issue_spec.rb +44 -48
- data/spec/integration/issuelinktype_spec.rb +8 -11
- data/spec/integration/issuetype_spec.rb +5 -7
- data/spec/integration/priority_spec.rb +5 -8
- data/spec/integration/project_spec.rb +13 -20
- data/spec/integration/rapidview_spec.rb +17 -10
- data/spec/integration/resolution_spec.rb +7 -10
- data/spec/integration/status_spec.rb +5 -8
- data/spec/integration/transition_spec.rb +17 -20
- data/spec/integration/user_spec.rb +24 -8
- data/spec/integration/version_spec.rb +21 -25
- data/spec/integration/watcher_spec.rb +28 -34
- data/spec/integration/webhook.rb +8 -17
- data/spec/integration/worklog_spec.rb +30 -34
- data/spec/jira/base_factory_spec.rb +11 -12
- data/spec/jira/base_spec.rb +204 -228
- data/spec/jira/client_spec.rb +26 -28
- data/spec/jira/has_many_proxy_spec.rb +11 -12
- data/spec/jira/http_client_spec.rb +51 -52
- data/spec/jira/http_error_spec.rb +7 -9
- data/spec/jira/oauth_client_spec.rb +44 -46
- data/spec/jira/request_client_spec.rb +5 -5
- data/spec/jira/resource/agile_spec.rb +5 -7
- data/spec/jira/resource/attachment_spec.rb +25 -26
- data/spec/jira/resource/board_spec.rb +175 -0
- data/spec/jira/resource/createmeta_spec.rb +29 -32
- data/spec/jira/resource/field_spec.rb +42 -48
- data/spec/jira/resource/filter_spec.rb +40 -40
- data/spec/jira/resource/issue_spec.rb +87 -89
- data/spec/jira/resource/issuelink_spec.rb +1 -1
- data/spec/jira/resource/project_factory_spec.rb +2 -4
- data/spec/jira/resource/project_spec.rb +33 -33
- data/spec/jira/resource/sprint_spec.rb +78 -0
- data/spec/jira/resource/user_factory_spec.rb +6 -8
- data/spec/jira/resource/worklog_spec.rb +9 -11
- data/spec/spec_helper.rb +8 -9
- data/spec/support/clients_helper.rb +4 -4
- data/spec/support/shared_examples/integration.rb +60 -77
- metadata +59 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5433f708b438c961d0ca07b8aa60ae7733382aecb7374d4cc3ea3af1947f0e7f
|
4
|
+
data.tar.gz: d6757f05e80e8c005ad0f20461fac98d5509f87f0e0bebaea025e43e7d180d3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25f924c28544baf800585f9243d6d29622b0facab654aa03cf620bf76e4133731334b649c6af725fb0f246c68e3f5aa17bd8623eba5c2dd66303d2f2b2766dd2
|
7
|
+
data.tar.gz: b15c6540010df98f03acd562a50520dd90705bfa58cb2815070bc0ba3a535aea00d092c61a0f58bd3e3f23345c8ee48cf14e5d602fe324c3f7197b408d64e252
|
data/Gemfile
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
-
source
|
1
|
+
source 'http://rubygems.org'
|
2
2
|
|
3
3
|
group :development do
|
4
|
+
gem 'guard'
|
5
|
+
gem 'guard-rspec'
|
4
6
|
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
|
5
7
|
end
|
6
8
|
|
9
|
+
group :development, :test do
|
10
|
+
gem 'pry' # this was in the original Gemfile - but only needed in development & test
|
11
|
+
end
|
12
|
+
|
7
13
|
# Specify your gem's dependencies in jira_api.gemspec
|
8
14
|
gemspec
|
data/Guardfile
CHANGED
data/Rakefile
CHANGED
@@ -6,25 +6,24 @@ require 'rdoc/task'
|
|
6
6
|
|
7
7
|
Dir.glob('lib/tasks/*.rake').each { |r| import r }
|
8
8
|
|
9
|
-
task :
|
9
|
+
task default: [:test]
|
10
10
|
|
11
|
-
task :
|
11
|
+
task test: %i[prepare spec]
|
12
12
|
|
13
13
|
desc 'Prepare and run rspec tests'
|
14
14
|
task :prepare do
|
15
15
|
rsa_key = File.expand_path('rsakey.pem')
|
16
|
-
unless File.
|
16
|
+
unless File.exist?(rsa_key)
|
17
17
|
raise 'rsakey.pem does not exist, tests will fail. Run `rake jira:generate_public_cert` first'
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
desc 'Run RSpec tests'
|
22
|
-
#RSpec::Core::RakeTask.new(:spec)
|
22
|
+
# RSpec::Core::RakeTask.new(:spec)
|
23
23
|
RSpec::Core::RakeTask.new(:spec) do |task|
|
24
24
|
task.rspec_opts = ['--color', '--format', 'doc']
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
27
|
Rake::RDocTask.new(:doc) do |rd|
|
29
28
|
rd.main = 'README.rdoc'
|
30
29
|
rd.rdoc_dir = 'doc'
|
data/http-basic-example.rb
CHANGED
@@ -2,29 +2,30 @@ require 'rubygems'
|
|
2
2
|
require 'pp'
|
3
3
|
require 'jira-ruby'
|
4
4
|
|
5
|
-
if ARGV.
|
5
|
+
if ARGV.empty?
|
6
6
|
# If not passed any command line arguments, prompt the
|
7
7
|
# user for the username and password.
|
8
|
-
puts
|
8
|
+
puts 'Enter the username: '
|
9
9
|
username = gets.strip
|
10
10
|
|
11
|
-
puts
|
11
|
+
puts 'Enter the password: '
|
12
12
|
password = gets.strip
|
13
13
|
elsif ARGV.length == 2
|
14
|
-
username
|
14
|
+
username = ARGV[0]
|
15
|
+
password = ARGV[1]
|
15
16
|
else
|
16
17
|
# Script must be passed 0 or 2 arguments
|
17
|
-
raise "Usage: #{$
|
18
|
+
raise "Usage: #{$PROGRAM_NAME} [ username password ]"
|
18
19
|
end
|
19
20
|
|
20
21
|
options = {
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
username: username,
|
23
|
+
password: password,
|
24
|
+
site: 'http://localhost:8080/',
|
25
|
+
context_path: '',
|
26
|
+
auth_type: :basic,
|
27
|
+
use_ssl: false
|
28
|
+
}
|
28
29
|
|
29
30
|
client = JIRA::Client.new(options)
|
30
31
|
|
data/jira-ruby.gemspec
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
$:.push File.expand_path('../lib', __FILE__)
|
1
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
3
2
|
require 'jira/version'
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
@@ -7,8 +6,8 @@ Gem::Specification.new do |s|
|
|
7
6
|
s.version = JIRA::VERSION
|
8
7
|
s.authors = ['SUMO Heavy Industries', 'test IO']
|
9
8
|
s.homepage = 'http://www.sumoheavy.com'
|
10
|
-
s.summary =
|
11
|
-
s.description =
|
9
|
+
s.summary = 'Ruby Gem for use with the Atlassian JIRA REST API'
|
10
|
+
s.description = 'API for JIRA'
|
12
11
|
s.licenses = ['MIT']
|
13
12
|
s.metadata = { 'source_code_uri' => 'https://github.com/sumoheavy/jira-ruby' }
|
14
13
|
|
@@ -18,20 +17,20 @@ Gem::Specification.new do |s|
|
|
18
17
|
|
19
18
|
s.files = `git ls-files`.split("\n")
|
20
19
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
22
21
|
s.require_paths = ['lib']
|
23
22
|
|
24
23
|
# Runtime Dependencies
|
25
|
-
s.add_runtime_dependency 'oauth', '~> 0.5', '>= 0.5.0'
|
26
24
|
s.add_runtime_dependency 'activesupport'
|
27
25
|
s.add_runtime_dependency 'multipart-post'
|
26
|
+
s.add_runtime_dependency 'oauth', '~> 0.5', '>= 0.5.0'
|
28
27
|
|
29
28
|
# Development Dependencies
|
30
|
-
s.add_development_dependency 'railties'
|
31
|
-
s.add_development_dependency 'webmock', '~> 1.18', '>= 1.18.0'
|
32
|
-
s.add_development_dependency 'rspec', '~> 3.0', '>= 3.0.0'
|
33
|
-
s.add_development_dependency 'rake', '~> 10.3', '>= 10.3.2'
|
34
29
|
s.add_development_dependency 'guard', '~> 2.13', '>= 2.13.0'
|
35
30
|
s.add_development_dependency 'guard-rspec', '~> 4.6', '>= 4.6.5'
|
36
31
|
s.add_development_dependency 'pry', '~> 0.10', '>= 0.10.3'
|
32
|
+
s.add_development_dependency 'railties'
|
33
|
+
s.add_development_dependency 'rake', '~> 10.3', '>= 10.3.2'
|
34
|
+
s.add_development_dependency 'rspec', '~> 3.0', '>= 3.0.0'
|
35
|
+
s.add_development_dependency 'webmock', '~> 1.18', '>= 1.18.0'
|
37
36
|
end
|
data/lib/jira-ruby.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
$LOAD_PATH << __dir__
|
2
2
|
|
3
3
|
require 'active_support/inflector'
|
4
4
|
ActiveSupport::Inflector.inflections do |inflector|
|
@@ -26,6 +26,8 @@ require 'jira/resource/applinks'
|
|
26
26
|
require 'jira/resource/issuelinktype'
|
27
27
|
require 'jira/resource/issuelink'
|
28
28
|
require 'jira/resource/remotelink'
|
29
|
+
require 'jira/resource/sprint'
|
30
|
+
require 'jira/resource/sprint_report'
|
29
31
|
require 'jira/resource/issue'
|
30
32
|
require 'jira/resource/filter'
|
31
33
|
require 'jira/resource/field'
|
@@ -35,7 +37,8 @@ require 'jira/resource/serverinfo'
|
|
35
37
|
require 'jira/resource/createmeta'
|
36
38
|
require 'jira/resource/webhook'
|
37
39
|
require 'jira/resource/agile'
|
38
|
-
require 'jira/resource/
|
40
|
+
require 'jira/resource/board'
|
41
|
+
|
39
42
|
require 'jira/request_client'
|
40
43
|
require 'jira/oauth_client'
|
41
44
|
require 'jira/http_client'
|
data/lib/jira/base.rb
CHANGED
@@ -3,7 +3,6 @@ require 'active_support/inflector'
|
|
3
3
|
require 'set'
|
4
4
|
|
5
5
|
module JIRA
|
6
|
-
|
7
6
|
# This class provides the basic object <-> REST mapping for all JIRA::Resource subclasses,
|
8
7
|
# i.e. the Create, Retrieve, Update, Delete lifecycle methods.
|
9
8
|
#
|
@@ -51,8 +50,8 @@ module JIRA
|
|
51
50
|
# new_comment = issue.comments.build
|
52
51
|
#
|
53
52
|
class Base
|
54
|
-
QUERY_PARAMS_FOR_SINGLE_FETCH = Set.new [
|
55
|
-
QUERY_PARAMS_FOR_SEARCH = Set.new [
|
53
|
+
QUERY_PARAMS_FOR_SINGLE_FETCH = Set.new %i[expand fields]
|
54
|
+
QUERY_PARAMS_FOR_SEARCH = Set.new %i[expand fields startAt maxResults]
|
56
55
|
|
57
56
|
# A reference to the JIRA::Client used to initialize this resource.
|
58
57
|
attr_reader :client
|
@@ -67,8 +66,8 @@ module JIRA
|
|
67
66
|
# representation of the JSON returned from the JIRA API
|
68
67
|
attr_accessor :attrs
|
69
68
|
|
70
|
-
alias
|
71
|
-
alias
|
69
|
+
alias expanded? expanded
|
70
|
+
alias deleted? deleted
|
72
71
|
|
73
72
|
def initialize(client, options = {})
|
74
73
|
@client = client
|
@@ -80,12 +79,12 @@ module JIRA
|
|
80
79
|
# each of them must be passed in to the initializer.
|
81
80
|
self.class.belongs_to_relationships.each do |relation|
|
82
81
|
if options[relation]
|
83
|
-
instance_variable_set("@#{relation
|
84
|
-
instance_variable_set("@#{relation
|
82
|
+
instance_variable_set("@#{relation}", options[relation])
|
83
|
+
instance_variable_set("@#{relation}_id", options[relation].key_value)
|
85
84
|
elsif options["#{relation}_id".to_sym]
|
86
|
-
instance_variable_set("@#{relation
|
85
|
+
instance_variable_set("@#{relation}_id", options["#{relation}_id".to_sym])
|
87
86
|
else
|
88
|
-
raise ArgumentError
|
87
|
+
raise ArgumentError, "Required option #{relation.inspect} missing" unless options[relation]
|
89
88
|
end
|
90
89
|
end
|
91
90
|
end
|
@@ -95,17 +94,15 @@ module JIRA
|
|
95
94
|
def self.all(client, options = {})
|
96
95
|
response = client.get(collection_path(client))
|
97
96
|
json = parse_json(response.body)
|
98
|
-
if collection_attributes_are_nested
|
99
|
-
json = json[endpoint_name.pluralize]
|
100
|
-
end
|
97
|
+
json = json[endpoint_name.pluralize] if collection_attributes_are_nested
|
101
98
|
json.map do |attrs|
|
102
|
-
|
99
|
+
new(client, { attrs: attrs }.merge(options))
|
103
100
|
end
|
104
101
|
end
|
105
102
|
|
106
103
|
# Finds and retrieves a resource with the given ID.
|
107
104
|
def self.find(client, key, options = {})
|
108
|
-
instance =
|
105
|
+
instance = new(client, options)
|
109
106
|
instance.attrs[key_attribute.to_s] = key
|
110
107
|
instance.fetch(false, query_params_for_single_fetch(options))
|
111
108
|
instance
|
@@ -114,7 +111,7 @@ module JIRA
|
|
114
111
|
# Builds a new instance of the resource with the given attributes.
|
115
112
|
# These attributes will be posted to the JIRA Api if save is called.
|
116
113
|
def self.build(client, attrs)
|
117
|
-
|
114
|
+
new(client, attrs: attrs)
|
118
115
|
end
|
119
116
|
|
120
117
|
# Returns the name of this resource for use in URL components.
|
@@ -122,7 +119,7 @@ module JIRA
|
|
122
119
|
# JIRA::Resource::Issue.endpoint_name
|
123
120
|
# # => issue
|
124
121
|
def self.endpoint_name
|
125
|
-
|
122
|
+
name.split('::').last.downcase
|
126
123
|
end
|
127
124
|
|
128
125
|
# Returns the full path for a collection of this resource.
|
@@ -130,7 +127,7 @@ module JIRA
|
|
130
127
|
# JIRA::Resource::Issue.collection_path
|
131
128
|
# # => /jira/rest/api/2/issue
|
132
129
|
def self.collection_path(client, prefix = '/')
|
133
|
-
client.options[:rest_base_path] + prefix +
|
130
|
+
client.options[:rest_base_path] + prefix + endpoint_name
|
134
131
|
end
|
135
132
|
|
136
133
|
# Returns the singular path for the resource with the given key.
|
@@ -200,7 +197,7 @@ module JIRA
|
|
200
197
|
define_method(resource) do
|
201
198
|
attribute = maybe_nested_attribute(attribute_key, options[:nested_under])
|
202
199
|
return nil unless attribute
|
203
|
-
child_class.new(client, :
|
200
|
+
child_class.new(client, attrs: attribute)
|
204
201
|
end
|
205
202
|
end
|
206
203
|
|
@@ -248,12 +245,12 @@ module JIRA
|
|
248
245
|
def self.has_many(collection, options = {})
|
249
246
|
attribute_key = options[:attribute_key] || collection.to_s
|
250
247
|
child_class = options[:class] || ('JIRA::Resource::' + collection.to_s.classify).constantize
|
251
|
-
self_class_basename =
|
248
|
+
self_class_basename = name.split('::').last.downcase.to_sym
|
252
249
|
define_method(collection) do
|
253
|
-
child_class_options = {self_class_basename => self}
|
250
|
+
child_class_options = { self_class_basename => self }
|
254
251
|
attribute = maybe_nested_attribute(attribute_key, options[:nested_under]) || []
|
255
252
|
collection = attribute.map do |child_attributes|
|
256
|
-
child_class.new(client, child_class_options.merge(:
|
253
|
+
child_class.new(client, child_class_options.merge(attrs: child_attributes))
|
257
254
|
end
|
258
255
|
HasManyProxy.new(self, child_class, collection)
|
259
256
|
end
|
@@ -290,8 +287,8 @@ module JIRA
|
|
290
287
|
# Checks if method_name is set in the attributes hash
|
291
288
|
# and returns true when found, otherwise proxies the
|
292
289
|
# call to the superclass.
|
293
|
-
def respond_to?(method_name,
|
294
|
-
if attrs.
|
290
|
+
def respond_to?(method_name, _include_all = false)
|
291
|
+
if attrs.key?(method_name.to_s)
|
295
292
|
true
|
296
293
|
else
|
297
294
|
super(method_name)
|
@@ -301,8 +298,8 @@ module JIRA
|
|
301
298
|
# Overrides method_missing to check the attribute hash
|
302
299
|
# for resources matching method_name and proxies the call
|
303
300
|
# to the superclass if no match is found.
|
304
|
-
def method_missing(method_name, *
|
305
|
-
if attrs.
|
301
|
+
def method_missing(method_name, *_args)
|
302
|
+
if attrs.key?(method_name.to_s)
|
306
303
|
attrs[method_name.to_s]
|
307
304
|
else
|
308
305
|
super(method_name)
|
@@ -315,7 +312,7 @@ module JIRA
|
|
315
312
|
@attrs[self.class.key_attribute.to_s]
|
316
313
|
end
|
317
314
|
|
318
|
-
def collection_path(prefix =
|
315
|
+
def collection_path(prefix = '/')
|
319
316
|
# Just proxy this to the class method
|
320
317
|
self.class.collection_path(client, prefix)
|
321
318
|
end
|
@@ -325,9 +322,7 @@ module JIRA
|
|
325
322
|
# issue it returns '/issue'
|
326
323
|
def path_component
|
327
324
|
path_component = "/#{self.class.endpoint_name}"
|
328
|
-
if key_value
|
329
|
-
path_component += '/' + key_value
|
330
|
-
end
|
325
|
+
path_component += '/' + key_value if key_value
|
331
326
|
path_component
|
332
327
|
end
|
333
328
|
|
@@ -346,9 +341,10 @@ module JIRA
|
|
346
341
|
#
|
347
342
|
# Accepts an attributes hash of the values to be saved. Will throw a
|
348
343
|
# JIRA::HTTPError if the request fails (response is not HTTP 2xx).
|
349
|
-
def save!(attrs)
|
344
|
+
def save!(attrs, path = nil)
|
345
|
+
path ||= new_record? ? url : patched_url
|
350
346
|
http_method = new_record? ? :post : :put
|
351
|
-
response = client.send(http_method,
|
347
|
+
response = client.send(http_method, path, attrs.to_json)
|
352
348
|
set_attrs(attrs, false)
|
353
349
|
set_attrs_from_response(response)
|
354
350
|
@expanded = false
|
@@ -360,19 +356,18 @@ module JIRA
|
|
360
356
|
#
|
361
357
|
# Accepts an attributes hash of the values to be saved. Will return false
|
362
358
|
# if the request fails.
|
363
|
-
def save(attrs)
|
359
|
+
def save(attrs, path = url)
|
364
360
|
begin
|
365
|
-
save_status = save!(attrs)
|
361
|
+
save_status = save!(attrs, path)
|
366
362
|
rescue JIRA::HTTPError => exception
|
367
363
|
begin
|
368
364
|
set_attrs_from_response(exception.response) # Merge error status generated by JIRA REST API
|
369
365
|
rescue JSON::ParserError => parse_exception
|
370
|
-
set_attrs(
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
}
|
375
|
-
)
|
366
|
+
set_attrs('exception' => {
|
367
|
+
'class' => exception.response.class.name,
|
368
|
+
'code' => exception.response.code,
|
369
|
+
'message' => exception.response.message
|
370
|
+
})
|
376
371
|
end
|
377
372
|
# raise exception
|
378
373
|
save_status = false
|
@@ -383,7 +378,7 @@ module JIRA
|
|
383
378
|
# Sets the attributes hash from a HTTPResponse object from JIRA if it is
|
384
379
|
# not nil or is not a json response.
|
385
380
|
def set_attrs_from_response(response)
|
386
|
-
unless response.body.nil?
|
381
|
+
unless response.body.nil? || (response.body.length < 2)
|
387
382
|
json = self.class.parse_json(response.body)
|
388
383
|
set_attrs(json)
|
389
384
|
end
|
@@ -393,7 +388,7 @@ module JIRA
|
|
393
388
|
# hash values will be clobbered by the new hash, otherwise the hash will
|
394
389
|
# be deeply merged into attrs. The target paramater is for internal use only
|
395
390
|
# and should not be used.
|
396
|
-
def set_attrs(hash, clobber=true, target = nil)
|
391
|
+
def set_attrs(hash, clobber = true, target = nil)
|
397
392
|
target ||= @attrs
|
398
393
|
if clobber
|
399
394
|
target.merge!(hash)
|
@@ -424,7 +419,7 @@ module JIRA
|
|
424
419
|
prefix = '/'
|
425
420
|
unless self.class.belongs_to_relationships.empty?
|
426
421
|
prefix = self.class.belongs_to_relationships.inject(prefix) do |prefix_so_far, relationship|
|
427
|
-
prefix_so_far.to_s + relationship.to_s +
|
422
|
+
prefix_so_far.to_s + relationship.to_s + '/' + send("#{relationship}_id").to_s + '/'
|
428
423
|
end
|
429
424
|
end
|
430
425
|
if @attrs['self']
|
@@ -494,9 +489,15 @@ module JIRA
|
|
494
489
|
end
|
495
490
|
|
496
491
|
def url_with_query_params(url, query_params)
|
497
|
-
|
498
|
-
|
499
|
-
|
492
|
+
self.class.url_with_query_params(url, query_params)
|
493
|
+
end
|
494
|
+
|
495
|
+
def self.url_with_query_params(url, query_params)
|
496
|
+
if !query_params.empty?
|
497
|
+
"#{url}?#{hash_to_query_string query_params}"
|
498
|
+
else
|
499
|
+
url
|
500
|
+
end
|
500
501
|
end
|
501
502
|
|
502
503
|
def hash_to_query_string(query_params)
|
@@ -504,19 +505,19 @@ module JIRA
|
|
504
505
|
end
|
505
506
|
|
506
507
|
def self.hash_to_query_string(query_params)
|
507
|
-
query_params.map do |k,v|
|
508
|
+
query_params.map do |k, v|
|
508
509
|
CGI.escape(k.to_s) + '=' + CGI.escape(v.to_s)
|
509
510
|
end.join('&')
|
510
511
|
end
|
511
512
|
|
512
513
|
def self.query_params_for_single_fetch(options)
|
513
|
-
Hash[options.select do |k,
|
514
|
+
Hash[options.select do |k, _v|
|
514
515
|
QUERY_PARAMS_FOR_SINGLE_FETCH.include? k
|
515
516
|
end]
|
516
517
|
end
|
517
518
|
|
518
519
|
def self.query_params_for_search(options)
|
519
|
-
Hash[options.select do |k,
|
520
|
+
Hash[options.select do |k, _v|
|
520
521
|
QUERY_PARAMS_FOR_SEARCH.include? k
|
521
522
|
end]
|
522
523
|
end
|
data/lib/jira/base_factory.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
module JIRA
|
2
|
-
|
3
2
|
# This is the base class for all the JIRA resource factory instances.
|
4
3
|
class BaseFactory
|
5
|
-
|
6
4
|
attr_reader :client
|
7
5
|
|
8
6
|
def initialize(client)
|
@@ -41,9 +39,8 @@ module JIRA
|
|
41
39
|
delegate_to_target_class :all, :find, :collection_path, :singular_path, :jql, :get_backlog_issues, :get_board_issues, :get_sprints, :get_sprint_issues, :get_projects, :get_projects_full
|
42
40
|
|
43
41
|
# This method needs special handling as it has a default argument value
|
44
|
-
def build(attrs={})
|
42
|
+
def build(attrs = {})
|
45
43
|
target_class.build(@client, attrs)
|
46
44
|
end
|
47
|
-
|
48
45
|
end
|
49
46
|
end
|