jira-ruby 0.1.14 → 0.1.16
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 +4 -4
- data/Gemfile +2 -0
- data/lib/jira/base.rb +17 -2
- data/lib/jira/request_client.rb +2 -0
- data/lib/jira/resource/issue.rb +11 -6
- data/lib/jira/resource/project.rb +10 -0
- data/lib/jira/version.rb +1 -1
- data/spec/integration/issue_spec.rb +1 -1
- data/spec/jira/resource/issue_spec.rb +44 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e40d5ee749de621839801a5e80f92e4cda3325d
|
4
|
+
data.tar.gz: 35a5726e608c149b40ee31fbbd5d262876bfc710
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdc3298da60ff9bd8553253c6abe2d87c7402bd970678d49e889f6b642f774654f80a234ab2a58ae2d066db84d9c1e5d329d72c59ac6c48a87226eba15e0ca8f
|
7
|
+
data.tar.gz: 42c0599010e58238193759fd88d0ad8b4a529311862432610f8e175fa3e584f8e3264dbebca71a029c1be791341aa280e6ebe6c2521e5045699cecb18ecda002
|
data/Gemfile
CHANGED
data/lib/jira/base.rb
CHANGED
@@ -364,6 +364,7 @@ module JIRA
|
|
364
364
|
begin
|
365
365
|
save_status = save!(attrs)
|
366
366
|
rescue JIRA::HTTPError => exception
|
367
|
+
puts ">>>>>>>>> Exception response: #{exception.response.body}"
|
367
368
|
set_attrs_from_response(exception.response) rescue JSON::ParserError # Merge error status generated by JIRA REST API
|
368
369
|
save_status = false
|
369
370
|
end
|
@@ -414,11 +415,13 @@ module JIRA
|
|
414
415
|
prefix = '/'
|
415
416
|
unless self.class.belongs_to_relationships.empty?
|
416
417
|
prefix = self.class.belongs_to_relationships.inject(prefix) do |prefix_so_far, relationship|
|
417
|
-
prefix_so_far + relationship.to_s + "/" + self.send("#{relationship.to_s}_id") + '/'
|
418
|
+
prefix_so_far.to_s + relationship.to_s + "/" + self.send("#{relationship.to_s}_id").to_s + '/'
|
418
419
|
end
|
419
420
|
end
|
420
421
|
if @attrs['self']
|
421
|
-
@attrs['self'].sub(@client.options[:site],'')
|
422
|
+
the_url = @attrs['self'].sub(@client.options[:site],'')
|
423
|
+
the_url = "/#{the_url}" if (the_url =~ /^\//).nil?
|
424
|
+
the_url
|
422
425
|
elsif key_value
|
423
426
|
self.class.singular_path(client, key_value.to_s, prefix)
|
424
427
|
else
|
@@ -426,6 +429,18 @@ module JIRA
|
|
426
429
|
end
|
427
430
|
end
|
428
431
|
|
432
|
+
# This method fixes issue that there is no / prefix in url. It is happened when we call for instance
|
433
|
+
# issue.save() for existing resource.
|
434
|
+
# As a result we got error 400 from JIRA API:
|
435
|
+
# [07/Jun/2015:15:32:19 +0400] "PUT jira/rest/api/2/issue/10111 HTTP/1.1" 400 -
|
436
|
+
# After applying this fix we have normal response:
|
437
|
+
# [07/Jun/2015:15:17:18 +0400] "PUT /jira/rest/api/2/issue/10111 HTTP/1.1" 204 -
|
438
|
+
def patched_url
|
439
|
+
result = url
|
440
|
+
result if result.start_with?('/')
|
441
|
+
"/#{result}"
|
442
|
+
end
|
443
|
+
|
429
444
|
def to_s
|
430
445
|
"#<#{self.class.name}:#{object_id} @attrs=#{@attrs.inspect}>"
|
431
446
|
end
|
data/lib/jira/request_client.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'oauth'
|
2
2
|
require 'json'
|
3
3
|
require 'net/https'
|
4
|
+
#require 'pry'
|
4
5
|
|
5
6
|
module JIRA
|
6
7
|
class RequestClient
|
@@ -11,6 +12,7 @@ module JIRA
|
|
11
12
|
|
12
13
|
def request(*args)
|
13
14
|
response = make_request(*args)
|
15
|
+
#binding.pry unless response.kind_of?(Net::HTTPSuccess)
|
14
16
|
raise HTTPError.new(response) unless response.kind_of?(Net::HTTPSuccess)
|
15
17
|
response
|
16
18
|
end
|
data/lib/jira/resource/issue.rb
CHANGED
@@ -29,28 +29,33 @@ module JIRA
|
|
29
29
|
has_many :attachments, :nested_under => 'fields',
|
30
30
|
:attribute_key => 'attachment'
|
31
31
|
|
32
|
-
has_many :versions,
|
32
|
+
has_many :versions, :nested_under => 'fields'
|
33
|
+
has_many :fixVersions, :class => JIRA::Resource::Version,
|
34
|
+
:nested_under => 'fields'
|
33
35
|
|
34
36
|
has_many :worklogs, :nested_under => ['fields','worklog']
|
35
37
|
|
36
38
|
def self.all(client)
|
37
|
-
|
38
|
-
|
39
|
-
:expand => 'transitions.fields'
|
40
|
-
)
|
39
|
+
url = client.options[:rest_base_path] + "/search?expand=transitions.fields"
|
40
|
+
response = client.get(url)
|
41
41
|
json = parse_json(response.body)
|
42
42
|
json['issues'].map do |issue|
|
43
43
|
client.Issue.build(issue)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
def self.jql(client, jql, options = {fields: nil, start_at: nil, max_results: nil})
|
47
|
+
def self.jql(client, jql, options = {fields: nil, start_at: nil, max_results: nil, expand: nil})
|
48
48
|
url = client.options[:rest_base_path] + "/search?jql=" + CGI.escape(jql)
|
49
49
|
|
50
50
|
url << "&fields=#{options[:fields].map{ |value| CGI.escape(value.to_s) }.join(',')}" if options[:fields]
|
51
51
|
url << "&startAt=#{CGI.escape(options[:start_at].to_s)}" if options[:start_at]
|
52
52
|
url << "&maxResults=#{CGI.escape(options[:max_results].to_s)}" if options[:max_results]
|
53
53
|
|
54
|
+
if options[:expand]
|
55
|
+
options[:expand] = [options[:expand]] if options[:expand].is_a?(String)
|
56
|
+
url << "&expand=#{options[:expand].to_a.map{ |value| CGI.escape(value.to_s) }.join(',')}"
|
57
|
+
end
|
58
|
+
|
54
59
|
response = client.get(url)
|
55
60
|
json = parse_json(response.body)
|
56
61
|
json['issues'].map do |issue|
|
@@ -26,6 +26,16 @@ module JIRA
|
|
26
26
|
client.Issue.build(issue)
|
27
27
|
end
|
28
28
|
end
|
29
|
+
|
30
|
+
def users
|
31
|
+
users_url = client.options[:rest_base_path] + '/user/assignable/search'
|
32
|
+
query_params = {:project => self.key_value}
|
33
|
+
response = client.get(url_with_query_params(users_url, query_params))
|
34
|
+
json = self.class.parse_json(response.body)
|
35
|
+
json.map do |jira_user|
|
36
|
+
client.User.build(jira_user)
|
37
|
+
end
|
38
|
+
end
|
29
39
|
end
|
30
40
|
end
|
31
41
|
end
|
data/lib/jira/version.rb
CHANGED
@@ -46,7 +46,7 @@ describe JIRA::Resource::Issue do
|
|
46
46
|
}
|
47
47
|
}
|
48
48
|
before(:each) do
|
49
|
-
stub_request(:get, site_url + "/jira/rest/api/2/search").
|
49
|
+
stub_request(:get, site_url + "/jira/rest/api/2/search?expand=transitions.fields").
|
50
50
|
to_return(:status => 200, :body => get_mock_response('issue.json'))
|
51
51
|
end
|
52
52
|
it_should_behave_like "a resource with a collection GET endpoint"
|
@@ -29,8 +29,23 @@ describe JIRA::Resource::Issue do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
32
|
+
|
33
|
+
it "should find all issues" do
|
34
|
+
response = double()
|
35
|
+
issue = double()
|
36
|
+
|
37
|
+
allow(response).to receive(:body).and_return('{"issues":[{"id":"1","summary":"Bugs Everywhere"}]}')
|
38
|
+
expect(client).to receive(:get).with('/jira/rest/api/2/search?expand=transitions.fields').
|
39
|
+
and_return(response)
|
40
|
+
expect(client).to receive(:Issue).and_return(issue)
|
41
|
+
expect(issue).to receive(:build).with({"id"=>"1","summary"=>"Bugs Everywhere"})
|
42
|
+
|
43
|
+
issues = JIRA::Resource::Issue.all(client)
|
44
|
+
end
|
45
|
+
|
32
46
|
it "should find an issue by key or id" do
|
33
47
|
response = double()
|
48
|
+
|
34
49
|
allow(response).to receive(:body).and_return('{"key":"foo","id":"101"}')
|
35
50
|
allow(JIRA::Resource::Issue).to receive(:collection_path).and_return('/jira/rest/api/2/issue')
|
36
51
|
expect(client).to receive(:get).with('/jira/rest/api/2/issue/foo').
|
@@ -47,6 +62,7 @@ describe JIRA::Resource::Issue do
|
|
47
62
|
it "should search an issue with a jql query string" do
|
48
63
|
response = double()
|
49
64
|
issue = double()
|
65
|
+
|
50
66
|
allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}')
|
51
67
|
expect(client).to receive(:get).with('/jira/rest/api/2/search?jql=foo+bar').
|
52
68
|
and_return(response)
|
@@ -84,6 +100,34 @@ describe JIRA::Resource::Issue do
|
|
84
100
|
expect(JIRA::Resource::Issue.jql(client,'foo bar', start_at: 1, max_results: 3)).to eq([''])
|
85
101
|
end
|
86
102
|
|
103
|
+
it "should search an issue with a jql query string and string expand" do
|
104
|
+
response = double()
|
105
|
+
issue = double()
|
106
|
+
|
107
|
+
allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}')
|
108
|
+
expect(client).to receive(:get)
|
109
|
+
.with('/jira/rest/api/2/search?jql=foo+bar&expand=transitions')
|
110
|
+
.and_return(response)
|
111
|
+
expect(client).to receive(:Issue).and_return(issue)
|
112
|
+
expect(issue).to receive(:build).with(["key", "foo"]).and_return('')
|
113
|
+
|
114
|
+
expect(JIRA::Resource::Issue.jql(client,'foo bar', expand: 'transitions')).to eq([''])
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should search an issue with a jql query string and array expand" do
|
118
|
+
response = double()
|
119
|
+
issue = double()
|
120
|
+
|
121
|
+
allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}')
|
122
|
+
expect(client).to receive(:get)
|
123
|
+
.with('/jira/rest/api/2/search?jql=foo+bar&expand=transitions')
|
124
|
+
.and_return(response)
|
125
|
+
expect(client).to receive(:Issue).and_return(issue)
|
126
|
+
expect(issue).to receive(:build).with(["key", "foo"]).and_return('')
|
127
|
+
|
128
|
+
expect(JIRA::Resource::Issue.jql(client,'foo bar', expand: %w(transitions))).to eq([''])
|
129
|
+
end
|
130
|
+
|
87
131
|
it "provides direct accessors to the fields" do
|
88
132
|
subject = JIRA::Resource::Issue.new(client, :attrs => {'fields' => {'foo' =>'bar'}})
|
89
133
|
expect(subject).to respond_to(:foo)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jira-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SUMO Heavy Industries
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -231,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
231
|
version: '0'
|
232
232
|
requirements: []
|
233
233
|
rubyforge_project: jira-ruby
|
234
|
-
rubygems_version: 2.4.
|
234
|
+
rubygems_version: 2.4.8
|
235
235
|
signing_key:
|
236
236
|
specification_version: 4
|
237
237
|
summary: Ruby Gem for use with the Atlassian JIRA REST API
|