jira-ruby 3.0.0.beta1 → 3.0.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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/CI.yml +1 -0
  3. data/.github/workflows/codeql.yml +0 -4
  4. data/.gitignore +3 -1
  5. data/.rubocop.yml +5 -70
  6. data/.yardopts +4 -0
  7. data/lib/jira/base.rb +5 -13
  8. data/lib/jira/client.rb +59 -4
  9. data/lib/jira/has_many_proxy.rb +30 -28
  10. data/lib/jira/http_client.rb +64 -1
  11. data/lib/jira/oauth_client.rb +62 -0
  12. data/lib/jira/request_client.rb +26 -1
  13. data/lib/jira/resource/attachment.rb +88 -3
  14. data/lib/jira/resource/field.rb +4 -8
  15. data/lib/jira/resource/issue.rb +80 -11
  16. data/lib/jira/resource/issue_picker_suggestions.rb +1 -1
  17. data/lib/jira/resource/issuelink.rb +4 -3
  18. data/lib/jira/resource/project.rb +1 -1
  19. data/lib/jira/resource/sprint.rb +2 -2
  20. data/lib/jira/resource/watcher.rb +1 -1
  21. data/lib/jira/resource/webhook.rb +5 -1
  22. data/lib/jira/version.rb +1 -1
  23. data/lib/tasks/generate.rake +1 -1
  24. data/spec/integration/issue_spec.rb +2 -2
  25. data/spec/integration/project_spec.rb +2 -2
  26. data/spec/integration/rapidview_spec.rb +3 -3
  27. data/spec/integration/user_spec.rb +12 -3
  28. data/spec/integration/watcher_spec.rb +6 -2
  29. data/spec/integration/{webhook.rb → webhook_spec.rb} +8 -1
  30. data/spec/jira/base_factory_spec.rb +11 -2
  31. data/spec/jira/base_spec.rb +80 -57
  32. data/spec/jira/client_spec.rb +29 -27
  33. data/spec/jira/http_client_spec.rb +2 -2
  34. data/spec/jira/oauth_client_spec.rb +8 -4
  35. data/spec/jira/resource/agile_spec.rb +4 -4
  36. data/spec/jira/resource/attachment_spec.rb +36 -13
  37. data/spec/jira/resource/board_spec.rb +5 -5
  38. data/spec/jira/resource/field_spec.rb +23 -24
  39. data/spec/jira/resource/filter_spec.rb +3 -2
  40. data/spec/jira/resource/issue_spec.rb +103 -81
  41. data/spec/jira/resource/project_spec.rb +8 -8
  42. data/spec/jira/resource/sprint_spec.rb +23 -11
  43. data/spec/jira/resource/status_spec.rb +1 -1
  44. data/spec/jira/resource/user_factory_spec.rb +2 -2
  45. data/spec/jira/resource/worklog_spec.rb +1 -1
  46. data/spec/mock_responses/board/1_issues.json +2 -1
  47. data/spec/mock_responses/issue.json +1 -0
  48. data/spec/mock_responses/rapidview/SAMPLEPROJECT.issues.full.json +2 -1
  49. data/spec/mock_responses/rapidview/SAMPLEPROJECT.issues.json +2 -1
  50. data/spec/support/clients_helper.rb +2 -2
  51. data/spec/support/mock_client.rb +9 -0
  52. data/spec/support/mock_response.rb +8 -0
  53. data/spec/support/shared_examples/integration.rb +1 -1
  54. metadata +9 -10
@@ -43,7 +43,9 @@ describe JIRA::Resource::Sprint do
43
43
  let(:given_attrs) { { start_date: '2016-06-10' } }
44
44
 
45
45
  it 'calls save on the super class with the given attributes & agile url' do
46
- expect_any_instance_of(JIRA::Base).to receive(:save).with(given_attrs, agile_sprint_path)
46
+ mock_response = double('response', body: '{"id":"123"}')
47
+
48
+ expect(client).to receive(:post).with(agile_sprint_path, given_attrs.to_json).and_return(mock_response)
47
49
 
48
50
  sprint.save(given_attrs)
49
51
  end
@@ -51,7 +53,9 @@ describe JIRA::Resource::Sprint do
51
53
 
52
54
  context 'when attributes are not specified' do
53
55
  it 'calls save on the super class with the instance attributes & agile url' do
54
- expect_any_instance_of(JIRA::Base).to receive(:save).with(instance_attrs, agile_sprint_path)
56
+ mock_response = double('response', body: '{"id":"123"}')
57
+
58
+ expect(client).to receive(:post).with(agile_sprint_path, instance_attrs.to_json).and_return(mock_response)
55
59
 
56
60
  sprint.save
57
61
  end
@@ -59,7 +63,9 @@ describe JIRA::Resource::Sprint do
59
63
 
60
64
  context 'when providing the path argument' do
61
65
  it 'ignores it' do
62
- expect_any_instance_of(JIRA::Base).to receive(:save).with(instance_attrs, agile_sprint_path)
66
+ mock_response = double('response', body: '{"id":"123"}')
67
+
68
+ expect(client).to receive(:post).with(agile_sprint_path, instance_attrs.to_json).and_return(mock_response)
63
69
 
64
70
  sprint.save({}, 'mavenlink.com')
65
71
  end
@@ -77,7 +83,9 @@ describe JIRA::Resource::Sprint do
77
83
  let(:given_attrs) { { start_date: '2016-06-10' } }
78
84
 
79
85
  it 'calls save! on the super class with the given attributes & agile url' do
80
- expect_any_instance_of(JIRA::Base).to receive(:save!).with(given_attrs, agile_sprint_path)
86
+ mock_response = double('response', body: '{"id":"123"}')
87
+
88
+ expect(client).to receive(:post).with(agile_sprint_path, given_attrs.to_json).and_return(mock_response)
81
89
 
82
90
  sprint.save!(given_attrs)
83
91
  end
@@ -85,7 +93,9 @@ describe JIRA::Resource::Sprint do
85
93
 
86
94
  context 'when attributes are not specified' do
87
95
  it 'calls save! on the super class with the instance attributes & agile url' do
88
- expect_any_instance_of(JIRA::Base).to receive(:save!).with(instance_attrs, agile_sprint_path)
96
+ mock_response = double('response', body: '{"id":"123"}')
97
+
98
+ expect(client).to receive(:post).with(agile_sprint_path, instance_attrs.to_json).and_return(mock_response)
89
99
 
90
100
  sprint.save!
91
101
  end
@@ -93,14 +103,16 @@ describe JIRA::Resource::Sprint do
93
103
 
94
104
  context 'when providing the path argument' do
95
105
  it 'ignores it' do
96
- expect_any_instance_of(JIRA::Base).to receive(:save!).with(instance_attrs, agile_sprint_path)
106
+ mock_response = double('response', body: '{"id":"123"}')
107
+
108
+ expect(client).to receive(:post).with(agile_sprint_path, instance_attrs.to_json).and_return(mock_response)
97
109
 
98
110
  sprint.save!({}, 'mavenlink.com')
99
111
  end
100
112
  end
101
113
  end
102
114
 
103
- context 'an issue exists' do
115
+ context 'when an issue exists' do
104
116
  let(:issue_id) { 1001 }
105
117
  let(:post_issue_path) do
106
118
  described_class.agile_path(client, sprint.id)
@@ -115,18 +127,18 @@ describe JIRA::Resource::Sprint do
115
127
  { issues: [issue.id] }
116
128
  end
117
129
 
118
- describe '#add_issu' do
130
+ describe '#add_issue' do
119
131
  context 'when an issue is passed' do
120
132
  it 'posts with the issue id' do
121
133
  expect(client).to receive(:post).with(post_issue_path, post_issue_input.to_json)
122
134
 
123
- sprint.add_issue(issue)
135
+ expect(sprint.add_issue(issue)).to eq(issue)
124
136
  end
125
137
  end
126
138
  end
127
139
  end
128
140
 
129
- context 'multiple issues exists' do
141
+ context 'when multiple issues exist' do
130
142
  let(:issue_ids) { [1001, 1012] }
131
143
  let(:post_issue_path) do
132
144
  described_class.agile_path(client, sprint.id)
@@ -148,7 +160,7 @@ describe JIRA::Resource::Sprint do
148
160
  it 'posts with the issue id' do
149
161
  expect(client).to receive(:post).with(post_issue_path, post_issue_input.to_json)
150
162
 
151
- sprint.add_issues(issues)
163
+ expect(sprint.add_issues(issues)).to eq(issues)
152
164
  end
153
165
  end
154
166
  end
@@ -4,7 +4,7 @@ describe JIRA::Resource::Status do
4
4
  let(:client) do
5
5
  client = double(options: { rest_base_path: '/jira/rest/api/2' })
6
6
  allow(client).to receive(:Field).and_return(JIRA::Resource::FieldFactory.new(client))
7
- allow(client).to receive(:cache).and_return(OpenStruct.new)
7
+ allow(client).to receive(:field_map_cache).and_return(nil)
8
8
  client
9
9
  end
10
10
 
@@ -4,13 +4,13 @@ describe JIRA::Resource::UserFactory do
4
4
  subject { described_class.new(client) }
5
5
 
6
6
  let(:client) do
7
- instance_double('Client', options: { rest_base_path: '/jira/rest/api/2' })
7
+ instance_double(Client, options: { rest_base_path: '/jira/rest/api/2' })
8
8
  end
9
9
 
10
10
  describe '#myself' do
11
11
  let(:response) do
12
12
  instance_double(
13
- 'Response', body: get_mock_response('user_accountId=1234567890abcdef01234567.json')
13
+ Response, body: get_mock_response('user_accountId=1234567890abcdef01234567.json')
14
14
  )
15
15
  end
16
16
 
@@ -7,7 +7,7 @@ describe JIRA::Resource::Worklog do
7
7
  subject do
8
8
  described_class.new(client, issue_id: '99999', attrs: {
9
9
  'author' => { 'foo' => 'bar' },
10
- 'updateAuthor' => { 'foo' => 'bar' }
10
+ 'updateAuthor' => { 'foo' => 'bar' }
11
11
  })
12
12
  end
13
13
 
@@ -3,6 +3,7 @@
3
3
  "startAt": 0,
4
4
  "maxResults": 1000,
5
5
  "total": 9,
6
+ "isLast": true,
6
7
  "issues": [
7
8
  {
8
9
  "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
@@ -59,4 +60,4 @@
59
60
  "key": "SBT-19"
60
61
  }
61
62
  ]
62
- }
63
+ }
@@ -3,6 +3,7 @@
3
3
  "startAt": 0,
4
4
  "maxResults": 1000,
5
5
  "total": 11,
6
+ "isLast": true,
6
7
  "issues": [
7
8
  {
8
9
  "expand": "editmeta,renderedFields,transitions,changelog",
@@ -2,6 +2,7 @@
2
2
  "expand": "schema,names",
3
3
  "startAt": 0,
4
4
  "maxResults": 50,
5
+ "isLast": true,
5
6
  "total": 2,
6
7
  "issues": [
7
8
  {
@@ -273,4 +274,4 @@
273
274
  }
274
275
  }
275
276
  ]
276
- }
277
+ }
@@ -101,6 +101,7 @@
101
101
  },
102
102
  "canManageSprints": true,
103
103
  "maxIssuesExceeded": false,
104
+ "isLast": true,
104
105
  "queryResultLimit": 2147483647,
105
106
  "versionData": {
106
107
  "versionsPerProject": {
@@ -108,4 +109,4 @@
108
109
  },
109
110
  "canCreateVersion": true
110
111
  }
111
- }
112
+ }
@@ -1,5 +1,5 @@
1
1
  module ClientsHelper
2
- def with_each_client(&block)
2
+ def with_each_client(&)
3
3
  clients = {}
4
4
 
5
5
  oauth_client = JIRA::Client.new(consumer_key: 'foo', consumer_secret: 'bar')
@@ -9,6 +9,6 @@ module ClientsHelper
9
9
  basic_client = JIRA::Client.new(username: 'foo', password: 'bar', auth_type: :basic, use_ssl: false)
10
10
  clients['http://localhost:2990'] = basic_client
11
11
 
12
- clients.each(&block)
12
+ clients.each(&)
13
13
  end
14
14
  end
@@ -0,0 +1,9 @@
1
+ class Client
2
+ attr_reader :options
3
+
4
+ def initialize(options = {})
5
+ @options = options
6
+ end
7
+
8
+ def get(url) end
9
+ end
@@ -0,0 +1,8 @@
1
+ class Response
2
+ attr_reader :body, :status
3
+
4
+ def initialize(body, status = nil)
5
+ @body = body
6
+ @status = status
7
+ end
8
+ end
@@ -76,7 +76,7 @@ shared_examples 'a resource with JQL inputs and a collection GET endpoint' do
76
76
  it 'gets the collection' do
77
77
  stub_request(
78
78
  :get,
79
- "#{site_url}#{client.options[:rest_base_path]}/search?jql=#{CGI.escape(jql_query_string)}"
79
+ "#{site_url}#{client.options[:rest_base_path]}/search/jql?jql=#{CGI.escape(jql_query_string)}"
80
80
  ).to_return(status: 200, body: get_mock_response('issue.json'))
81
81
 
82
82
  collection = build_receiver.jql(jql_query_string)
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jira-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SUMO Heavy Industries
8
8
  - test IO
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2024-08-15 00:00:00.000000000 Z
11
+ date: 2025-09-15 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activesupport
@@ -68,7 +67,6 @@ dependencies:
68
67
  - !ruby/object:Gem::Version
69
68
  version: '1.0'
70
69
  description: API for JIRA
71
- email:
72
70
  executables: []
73
71
  extensions: []
74
72
  extra_rdoc_files: []
@@ -81,6 +79,7 @@ files:
81
79
  - ".github/workflows/rubocop.yml"
82
80
  - ".gitignore"
83
81
  - ".rubocop.yml"
82
+ - ".yardopts"
84
83
  - Gemfile
85
84
  - Guardfile
86
85
  - LICENSE
@@ -150,7 +149,7 @@ files:
150
149
  - spec/integration/user_spec.rb
151
150
  - spec/integration/version_spec.rb
152
151
  - spec/integration/watcher_spec.rb
153
- - spec/integration/webhook.rb
152
+ - spec/integration/webhook_spec.rb
154
153
  - spec/integration/worklog_spec.rb
155
154
  - spec/jira/base_factory_spec.rb
156
155
  - spec/jira/base_spec.rb
@@ -237,6 +236,8 @@ files:
237
236
  - spec/support/matchers/have_attributes.rb
238
237
  - spec/support/matchers/have_many.rb
239
238
  - spec/support/matchers/have_one.rb
239
+ - spec/support/mock_client.rb
240
+ - spec/support/mock_response.rb
240
241
  - spec/support/shared_examples/integration.rb
241
242
  homepage: http://www.sumoheavy.com
242
243
  licenses:
@@ -244,7 +245,6 @@ licenses:
244
245
  metadata:
245
246
  source_code_uri: https://github.com/sumoheavy/jira-ruby
246
247
  rubygems_mfa_required: 'true'
247
- post_install_message:
248
248
  rdoc_options: []
249
249
  require_paths:
250
250
  - lib
@@ -255,12 +255,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
255
255
  version: 3.1.0
256
256
  required_rubygems_version: !ruby/object:Gem::Requirement
257
257
  requirements:
258
- - - ">"
258
+ - - ">="
259
259
  - !ruby/object:Gem::Version
260
- version: 1.3.1
260
+ version: '0'
261
261
  requirements: []
262
- rubygems_version: 3.3.3
263
- signing_key:
262
+ rubygems_version: 3.6.2
264
263
  specification_version: 4
265
264
  summary: Ruby Gem for use with the Atlassian JIRA REST API
266
265
  test_files: []