jira-ruby 3.1.0 → 3.2.1
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/.github/workflows/codeql.yml +3 -3
- data/.github/workflows/{rubocop.yml → lint.yml} +3 -2
- data/.github/workflows/{CI.yml → test.yml} +2 -2
- data/README.md +2 -1
- data/jira-ruby.gemspec +1 -1
- data/lib/jira/atlassian/jwt.rb +76 -0
- data/lib/jira/base.rb +1 -0
- data/lib/jira/client.rb +10 -2
- data/lib/jira/jwt_client.rb +2 -2
- data/lib/jira/resource/attachment.rb +17 -2
- data/lib/jira/resource/comment.rb +12 -0
- data/lib/jira/resource/createmeta.rb +4 -4
- data/lib/jira/resource/issue.rb +1 -0
- data/lib/jira/resource/properties.rb +56 -0
- data/lib/jira/resource/worklog.rb +12 -0
- data/lib/jira/version.rb +1 -1
- data/lib/jira-ruby.rb +1 -0
- data/spec/data/files/jwt-signed-urls.json +317 -0
- data/spec/integration/properties_spec.rb +45 -0
- data/spec/integration/transition_spec.rb +3 -2
- data/spec/integration/webhook_spec.rb +4 -2
- data/spec/jira/atlassian/jwt_spec.rb +59 -0
- data/spec/jira/base_spec.rb +21 -0
- data/spec/jira/resource/issue_spec.rb +5 -1
- data/spec/mock_responses/issue/10002/properties/foo.json +4 -0
- data/spec/mock_responses/issue/10002/properties/xyz.json +4 -0
- data/spec/mock_responses/issue/10002/properties/xyz.put.json +4 -0
- data/spec/mock_responses/issue/10002/properties.json +12 -0
- data/spec/support/clients_helper.rb +3 -3
- data/spec/support/shared_examples/integration.rb +34 -38
- metadata +18 -11
- data/spec/mock_responses/jira/rest/webhooks/1.0/webhook.json +0 -11
- data/spec/mock_responses/webhook/webhook.json +0 -11
- /data/spec/mock_responses/{jira/rest/webhooks/1.0/webhook → webhook}/2.json +0 -0
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
require 'cgi'
|
|
2
2
|
|
|
3
|
-
def
|
|
4
|
-
prefix =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
end
|
|
17
|
-
file_path = url.sub(client.options[:rest_base_path], '')
|
|
3
|
+
def build_url(options = {})
|
|
4
|
+
prefix = defined?(belongs_to) ? "#{belongs_to.path_component}/" : '/'
|
|
5
|
+
path = if options.key?(:key)
|
|
6
|
+
described_class.singular_path(client, options[:key], prefix)
|
|
7
|
+
else
|
|
8
|
+
described_class.collection_path(client, prefix)
|
|
9
|
+
end
|
|
10
|
+
site_url + path
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def get_mock_from_url(method, url, options = {})
|
|
14
|
+
# Remove site_url and rest api portion of the url
|
|
15
|
+
file_path = url.sub(site_url + client.options[:rest_base_path], '')
|
|
18
16
|
file_path = "#{file_path}.#{options[:suffix]}" if options[:suffix]
|
|
19
17
|
file_path = "#{file_path}.#{method}" unless method == :get
|
|
20
18
|
value_if_not_found = options.key?(:value_if_not_found) ? options[:value_if_not_found] : false
|
|
@@ -63,8 +61,8 @@ end
|
|
|
63
61
|
|
|
64
62
|
shared_examples 'a resource with a collection GET endpoint' do
|
|
65
63
|
it 'gets the collection' do
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
req_url = build_url
|
|
65
|
+
stub_request(:get, req_url).to_return(status: 200, body: get_mock_from_url(:get, req_url))
|
|
68
66
|
collection = build_receiver.all
|
|
69
67
|
|
|
70
68
|
expect(collection.length).to eq(expected_collection_length)
|
|
@@ -74,10 +72,8 @@ end
|
|
|
74
72
|
|
|
75
73
|
shared_examples 'a resource with JQL inputs and a collection GET endpoint' do
|
|
76
74
|
it 'gets the collection' do
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"#{site_url}#{client.options[:rest_base_path]}/search/jql?jql=#{CGI.escape(jql_query_string)}"
|
|
80
|
-
).to_return(status: 200, body: get_mock_response('issue.json'))
|
|
75
|
+
req_url = "#{site_url}#{client.options[:rest_base_path]}/search/jql?jql=#{CGI.escape(jql_query_string)}"
|
|
76
|
+
stub_request(:get, req_url).to_return(status: 200, body: get_mock_response('issue.json'))
|
|
81
77
|
|
|
82
78
|
collection = build_receiver.jql(jql_query_string)
|
|
83
79
|
|
|
@@ -90,8 +86,8 @@ shared_examples 'a resource with a singular GET endpoint' do
|
|
|
90
86
|
it 'GETs a single resource' do
|
|
91
87
|
# E.g., for JIRA::Resource::Project, we need to call
|
|
92
88
|
# client.Project.find()
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
req_url = build_url(key:)
|
|
90
|
+
stub_request(:get, req_url).to_return(status: 200, body: get_mock_from_url(:get, req_url))
|
|
95
91
|
subject = client.send(class_basename).find(key, options)
|
|
96
92
|
|
|
97
93
|
expect(subject).to have_attributes(expected_attributes)
|
|
@@ -100,8 +96,8 @@ shared_examples 'a resource with a singular GET endpoint' do
|
|
|
100
96
|
it 'builds and fetches a single resource' do
|
|
101
97
|
# E.g., for JIRA::Resource::Project, we need to call
|
|
102
98
|
# client.Project.build('key' => 'ABC123')
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
req_url = build_url(key:)
|
|
100
|
+
stub_request(:get, req_url).to_return(status: 200, body: get_mock_from_url(:get, req_url))
|
|
105
101
|
|
|
106
102
|
subject = build_receiver.build(described_class.key_attribute.to_s => key)
|
|
107
103
|
subject.fetch
|
|
@@ -110,7 +106,7 @@ shared_examples 'a resource with a singular GET endpoint' do
|
|
|
110
106
|
end
|
|
111
107
|
|
|
112
108
|
it 'handles a 404' do
|
|
113
|
-
stub_request(:get,
|
|
109
|
+
stub_request(:get, build_url(key: '99999'))
|
|
114
110
|
.to_return(status: 404, body: "{\"errorMessages\":[\"#{class_basename} Does Not Exist\"],\"errors\": {}}")
|
|
115
111
|
expect do
|
|
116
112
|
client.send(class_basename).find('99999', options)
|
|
@@ -122,8 +118,8 @@ shared_examples 'a resource with a DELETE endpoint' do
|
|
|
122
118
|
it 'deletes a resource' do
|
|
123
119
|
# E.g., for JIRA::Resource::Project, we need to call
|
|
124
120
|
# client.Project.delete()
|
|
125
|
-
|
|
126
|
-
|
|
121
|
+
req_url = build_url(key:)
|
|
122
|
+
stub_request(:delete, req_url).to_return(status: 204, body: nil)
|
|
127
123
|
|
|
128
124
|
subject = build_receiver.build(described_class.key_attribute.to_s => key)
|
|
129
125
|
expect(subject.delete).to be_truthy
|
|
@@ -132,8 +128,8 @@ end
|
|
|
132
128
|
|
|
133
129
|
shared_examples 'a resource with a POST endpoint' do
|
|
134
130
|
it 'saves a new resource' do
|
|
135
|
-
|
|
136
|
-
|
|
131
|
+
req_url = build_url
|
|
132
|
+
stub_request(:post, req_url).to_return(status: 201, body: get_mock_from_url(:post, req_url))
|
|
137
133
|
subject = build_receiver.build
|
|
138
134
|
expect(subject.save(attributes_for_post)).to be_truthy
|
|
139
135
|
expected_attributes_from_post.each do |method_name, value|
|
|
@@ -144,10 +140,10 @@ end
|
|
|
144
140
|
|
|
145
141
|
shared_examples 'a resource with a PUT endpoint' do
|
|
146
142
|
it 'saves an existing component' do
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
stub_request(:put,
|
|
150
|
-
.to_return(status: 200, body:
|
|
143
|
+
req_url = build_url(key:)
|
|
144
|
+
stub_request(:get, req_url).to_return(status: 200, body: get_mock_from_url(:get, req_url))
|
|
145
|
+
stub_request(:put, req_url)
|
|
146
|
+
.to_return(status: 200, body: get_mock_from_url(:put, req_url, value_if_not_found: nil))
|
|
151
147
|
subject = build_receiver.build(described_class.key_attribute.to_s => key)
|
|
152
148
|
subject.fetch
|
|
153
149
|
expect(subject.save(attributes_for_put)).to be_truthy
|
|
@@ -159,10 +155,10 @@ end
|
|
|
159
155
|
|
|
160
156
|
shared_examples 'a resource with a PUT endpoint that rejects invalid fields' do
|
|
161
157
|
it 'fails to save with an invalid field' do
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
stub_request(:put,
|
|
165
|
-
.to_return(status: 400, body:
|
|
158
|
+
req_url = build_url(key:)
|
|
159
|
+
stub_request(:get, req_url).to_return(status: 200, body: get_mock_from_url(:get, req_url))
|
|
160
|
+
stub_request(:put, req_url)
|
|
161
|
+
.to_return(status: 400, body: get_mock_from_url(:put, req_url, suffix: 'invalid'))
|
|
166
162
|
subject = client.send(class_basename).build(described_class.key_attribute.to_s => key)
|
|
167
163
|
subject.fetch
|
|
168
164
|
|
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: 3.1
|
|
4
|
+
version: 3.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SUMO Heavy Industries
|
|
8
8
|
- test IO
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-07-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -25,7 +25,7 @@ dependencies:
|
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: cgi
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
@@ -39,19 +39,19 @@ dependencies:
|
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: jwt
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
47
|
+
version: '2.1'
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
54
|
+
version: '2.1'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: multipart-post
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -88,9 +88,9 @@ files:
|
|
|
88
88
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
|
89
89
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
|
90
90
|
- ".github/dependabot.yml"
|
|
91
|
-
- ".github/workflows/CI.yml"
|
|
92
91
|
- ".github/workflows/codeql.yml"
|
|
93
|
-
- ".github/workflows/
|
|
92
|
+
- ".github/workflows/lint.yml"
|
|
93
|
+
- ".github/workflows/test.yml"
|
|
94
94
|
- ".gitignore"
|
|
95
95
|
- ".rubocop.yml"
|
|
96
96
|
- ".yardopts"
|
|
@@ -101,6 +101,7 @@ files:
|
|
|
101
101
|
- Rakefile
|
|
102
102
|
- jira-ruby.gemspec
|
|
103
103
|
- lib/jira-ruby.rb
|
|
104
|
+
- lib/jira/atlassian/jwt.rb
|
|
104
105
|
- lib/jira/base.rb
|
|
105
106
|
- lib/jira/base_factory.rb
|
|
106
107
|
- lib/jira/client.rb
|
|
@@ -129,6 +130,7 @@ files:
|
|
|
129
130
|
- lib/jira/resource/issuetype.rb
|
|
130
131
|
- lib/jira/resource/priority.rb
|
|
131
132
|
- lib/jira/resource/project.rb
|
|
133
|
+
- lib/jira/resource/properties.rb
|
|
132
134
|
- lib/jira/resource/rapidview.rb
|
|
133
135
|
- lib/jira/resource/remotelink.rb
|
|
134
136
|
- lib/jira/resource/resolution.rb
|
|
@@ -145,6 +147,7 @@ files:
|
|
|
145
147
|
- lib/jira/resource/worklog.rb
|
|
146
148
|
- lib/jira/version.rb
|
|
147
149
|
- lib/tasks/generate.rake
|
|
150
|
+
- spec/data/files/jwt-signed-urls.json
|
|
148
151
|
- spec/data/files/short.txt
|
|
149
152
|
- spec/integration/attachment_spec.rb
|
|
150
153
|
- spec/integration/comment_spec.rb
|
|
@@ -155,6 +158,7 @@ files:
|
|
|
155
158
|
- spec/integration/issuetype_spec.rb
|
|
156
159
|
- spec/integration/priority_spec.rb
|
|
157
160
|
- spec/integration/project_spec.rb
|
|
161
|
+
- spec/integration/properties_spec.rb
|
|
158
162
|
- spec/integration/rapidview_spec.rb
|
|
159
163
|
- spec/integration/resolution_spec.rb
|
|
160
164
|
- spec/integration/status_category_spec.rb
|
|
@@ -165,6 +169,7 @@ files:
|
|
|
165
169
|
- spec/integration/watcher_spec.rb
|
|
166
170
|
- spec/integration/webhook_spec.rb
|
|
167
171
|
- spec/integration/worklog_spec.rb
|
|
172
|
+
- spec/jira/atlassian/jwt_spec.rb
|
|
168
173
|
- spec/jira/base_factory_spec.rb
|
|
169
174
|
- spec/jira/base_spec.rb
|
|
170
175
|
- spec/jira/client_spec.rb
|
|
@@ -208,6 +213,10 @@ files:
|
|
|
208
213
|
- spec/mock_responses/issue/10002/comment.post.json
|
|
209
214
|
- spec/mock_responses/issue/10002/comment/10000.json
|
|
210
215
|
- spec/mock_responses/issue/10002/comment/10000.put.json
|
|
216
|
+
- spec/mock_responses/issue/10002/properties.json
|
|
217
|
+
- spec/mock_responses/issue/10002/properties/foo.json
|
|
218
|
+
- spec/mock_responses/issue/10002/properties/xyz.json
|
|
219
|
+
- spec/mock_responses/issue/10002/properties/xyz.put.json
|
|
211
220
|
- spec/mock_responses/issue/10002/transitions.json
|
|
212
221
|
- spec/mock_responses/issue/10002/transitions.post.json
|
|
213
222
|
- spec/mock_responses/issue/10002/watchers.json
|
|
@@ -219,8 +228,6 @@ files:
|
|
|
219
228
|
- spec/mock_responses/issueLinkType/10000.json
|
|
220
229
|
- spec/mock_responses/issuetype.json
|
|
221
230
|
- spec/mock_responses/issuetype/5.json
|
|
222
|
-
- spec/mock_responses/jira/rest/webhooks/1.0/webhook.json
|
|
223
|
-
- spec/mock_responses/jira/rest/webhooks/1.0/webhook/2.json
|
|
224
231
|
- spec/mock_responses/priority.json
|
|
225
232
|
- spec/mock_responses/priority/1.json
|
|
226
233
|
- spec/mock_responses/project.json
|
|
@@ -244,7 +251,7 @@ files:
|
|
|
244
251
|
- spec/mock_responses/version/10000.json
|
|
245
252
|
- spec/mock_responses/version/10000.put.json
|
|
246
253
|
- spec/mock_responses/webhook.json
|
|
247
|
-
- spec/mock_responses/webhook/
|
|
254
|
+
- spec/mock_responses/webhook/2.json
|
|
248
255
|
- spec/spec_helper.rb
|
|
249
256
|
- spec/support/clients_helper.rb
|
|
250
257
|
- spec/support/matchers/have_attributes.rb
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
[{"name":"from API",
|
|
2
|
-
"url":"http://localhost:3000/webhooks/1",
|
|
3
|
-
"excludeBody":false,
|
|
4
|
-
"filters":{"issue-related-events-section":""},
|
|
5
|
-
"events":[],
|
|
6
|
-
"enabled":true,
|
|
7
|
-
"self":"http://localhost:2990/jira/rest/webhooks/1.0/webhook/2",
|
|
8
|
-
"lastUpdatedUser":"admin",
|
|
9
|
-
"lastUpdatedDisplayName":"admin",
|
|
10
|
-
"lastUpdated":1453306520188
|
|
11
|
-
}]
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{"name":"from API",
|
|
2
|
-
"url":"http://localhost:3000/webhooks/1",
|
|
3
|
-
"excludeBody":false,
|
|
4
|
-
"filters":{"issue-related-events-section":""},
|
|
5
|
-
"events":[],
|
|
6
|
-
"enabled":true,
|
|
7
|
-
"self":"http://localhost:2990/jira/rest/webhooks/1.0/webhook/2",
|
|
8
|
-
"lastUpdatedUser":"admin",
|
|
9
|
-
"lastUpdatedDisplayName":"admin",
|
|
10
|
-
"lastUpdated":1453306520188
|
|
11
|
-
}
|
|
File without changes
|