jira-ruby 2.3.0 → 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +20 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  4. data/.github/dependabot.yml +6 -0
  5. data/.github/workflows/CI.yml +28 -0
  6. data/.github/workflows/codeql.yml +100 -0
  7. data/.github/workflows/rubocop.yml +18 -0
  8. data/.rubocop.yml +188 -0
  9. data/Gemfile +11 -3
  10. data/Guardfile +2 -0
  11. data/README.md +94 -18
  12. data/Rakefile +3 -4
  13. data/jira-ruby.gemspec +11 -17
  14. data/lib/jira/base.rb +37 -28
  15. data/lib/jira/base_factory.rb +4 -1
  16. data/lib/jira/client.rb +64 -46
  17. data/lib/jira/has_many_proxy.rb +4 -2
  18. data/lib/jira/http_client.rb +17 -13
  19. data/lib/jira/http_error.rb +4 -0
  20. data/lib/jira/jwt_client.rb +18 -42
  21. data/lib/jira/oauth_client.rb +6 -3
  22. data/lib/jira/railtie.rb +2 -0
  23. data/lib/jira/request_client.rb +5 -1
  24. data/lib/jira/resource/agile.rb +7 -9
  25. data/lib/jira/resource/applinks.rb +5 -3
  26. data/lib/jira/resource/attachment.rb +43 -3
  27. data/lib/jira/resource/board.rb +5 -3
  28. data/lib/jira/resource/board_configuration.rb +2 -0
  29. data/lib/jira/resource/comment.rb +2 -0
  30. data/lib/jira/resource/component.rb +2 -0
  31. data/lib/jira/resource/createmeta.rb +3 -1
  32. data/lib/jira/resource/field.rb +9 -4
  33. data/lib/jira/resource/filter.rb +2 -0
  34. data/lib/jira/resource/issue.rb +35 -44
  35. data/lib/jira/resource/issue_picker_suggestions.rb +4 -1
  36. data/lib/jira/resource/issue_picker_suggestions_issue.rb +2 -0
  37. data/lib/jira/resource/issuelink.rb +2 -0
  38. data/lib/jira/resource/issuelinktype.rb +2 -0
  39. data/lib/jira/resource/issuetype.rb +2 -0
  40. data/lib/jira/resource/priority.rb +2 -0
  41. data/lib/jira/resource/project.rb +4 -2
  42. data/lib/jira/resource/rapidview.rb +5 -3
  43. data/lib/jira/resource/remotelink.rb +2 -0
  44. data/lib/jira/resource/resolution.rb +2 -0
  45. data/lib/jira/resource/serverinfo.rb +2 -0
  46. data/lib/jira/resource/sprint.rb +14 -23
  47. data/lib/jira/resource/status.rb +7 -1
  48. data/lib/jira/resource/status_category.rb +10 -0
  49. data/lib/jira/resource/suggested_issue.rb +2 -0
  50. data/lib/jira/resource/transition.rb +2 -0
  51. data/lib/jira/resource/user.rb +3 -1
  52. data/lib/jira/resource/version.rb +2 -0
  53. data/lib/jira/resource/watcher.rb +2 -1
  54. data/lib/jira/resource/webhook.rb +4 -2
  55. data/lib/jira/resource/worklog.rb +3 -2
  56. data/lib/jira/version.rb +3 -1
  57. data/lib/jira-ruby.rb +5 -3
  58. data/lib/tasks/generate.rake +4 -2
  59. data/spec/data/files/short.txt +1 -0
  60. data/spec/integration/attachment_spec.rb +3 -3
  61. data/spec/integration/comment_spec.rb +8 -8
  62. data/spec/integration/component_spec.rb +7 -7
  63. data/spec/integration/field_spec.rb +3 -3
  64. data/spec/integration/issue_spec.rb +20 -16
  65. data/spec/integration/issuelinktype_spec.rb +3 -3
  66. data/spec/integration/issuetype_spec.rb +3 -3
  67. data/spec/integration/priority_spec.rb +3 -3
  68. data/spec/integration/project_spec.rb +7 -7
  69. data/spec/integration/rapidview_spec.rb +9 -9
  70. data/spec/integration/resolution_spec.rb +3 -3
  71. data/spec/integration/status_category_spec.rb +20 -0
  72. data/spec/integration/status_spec.rb +4 -8
  73. data/spec/integration/transition_spec.rb +2 -2
  74. data/spec/integration/user_spec.rb +22 -8
  75. data/spec/integration/version_spec.rb +7 -7
  76. data/spec/integration/watcher_spec.rb +17 -18
  77. data/spec/integration/webhook.rb +5 -4
  78. data/spec/integration/worklog_spec.rb +8 -8
  79. data/spec/jira/base_factory_spec.rb +2 -1
  80. data/spec/jira/base_spec.rb +55 -41
  81. data/spec/jira/client_spec.rb +48 -34
  82. data/spec/jira/has_many_proxy_spec.rb +3 -3
  83. data/spec/jira/http_client_spec.rb +94 -27
  84. data/spec/jira/http_error_spec.rb +2 -2
  85. data/spec/jira/oauth_client_spec.rb +8 -6
  86. data/spec/jira/request_client_spec.rb +4 -4
  87. data/spec/jira/resource/agile_spec.rb +28 -28
  88. data/spec/jira/resource/attachment_spec.rb +142 -52
  89. data/spec/jira/resource/board_spec.rb +21 -20
  90. data/spec/jira/resource/createmeta_spec.rb +48 -48
  91. data/spec/jira/resource/field_spec.rb +30 -12
  92. data/spec/jira/resource/filter_spec.rb +4 -4
  93. data/spec/jira/resource/issue_picker_suggestions_spec.rb +17 -17
  94. data/spec/jira/resource/issue_spec.rb +43 -37
  95. data/spec/jira/resource/jira_picker_suggestions_issue_spec.rb +3 -3
  96. data/spec/jira/resource/project_factory_spec.rb +3 -2
  97. data/spec/jira/resource/project_spec.rb +16 -16
  98. data/spec/jira/resource/sprint_spec.rb +70 -3
  99. data/spec/jira/resource/status_spec.rb +21 -0
  100. data/spec/jira/resource/user_factory_spec.rb +4 -4
  101. data/spec/jira/resource/worklog_spec.rb +3 -3
  102. data/spec/mock_responses/sprint/1.json +13 -0
  103. data/spec/mock_responses/status/1.json +8 -1
  104. data/spec/mock_responses/status.json +40 -5
  105. data/spec/mock_responses/statuscategory/1.json +7 -0
  106. data/spec/mock_responses/statuscategory.json +30 -0
  107. data/spec/mock_responses/{user_username=admin.json → user_accountId=1234567890abcdef01234567.json} +2 -1
  108. data/spec/spec_helper.rb +1 -0
  109. data/spec/support/clients_helper.rb +3 -5
  110. data/spec/support/shared_examples/integration.rb +25 -28
  111. metadata +25 -257
  112. data/.travis.yml +0 -9
  113. data/example.rb +0 -232
  114. data/http-basic-example.rb +0 -113
  115. data/lib/jira/resource/sprint_report.rb +0 -8
  116. data/lib/jira/tasks.rb +0 -0
  117. data/spec/jira/jwt_uri_builder_spec.rb +0 -59
@@ -2,10 +2,10 @@ require 'spec_helper'
2
2
 
3
3
  describe JIRA::Resource::Attachment do
4
4
  subject(:attachment) do
5
- JIRA::Resource::Attachment.new(
6
- client,
7
- issue: JIRA::Resource::Issue.new(client),
8
- attrs: { 'author' => { 'foo' => 'bar' } }
5
+ described_class.new(
6
+ client,
7
+ issue: JIRA::Resource::Issue.new(client),
8
+ attrs: { 'author' => { 'foo' => 'bar' } }
9
9
  )
10
10
  end
11
11
 
@@ -35,12 +35,12 @@ describe JIRA::Resource::Attachment do
35
35
  end
36
36
 
37
37
  describe '.meta' do
38
- subject { JIRA::Resource::Attachment.meta(client) }
38
+ subject { described_class.meta(client) }
39
39
 
40
40
  let(:response) do
41
41
  double(
42
- 'response',
43
- body: '{"enabled":true,"uploadLimit":10485760}'
42
+ 'response',
43
+ body: '{"enabled":true,"uploadLimit":10485760}'
44
44
  )
45
45
  end
46
46
 
@@ -59,79 +59,169 @@ describe JIRA::Resource::Attachment do
59
59
  end
60
60
  end
61
61
 
62
- describe '#save' do
63
- subject { attachment.save('file' => path_to_file) }
64
- let(:path_to_file) { './spec/mock_responses/issue.json' }
65
- let(:response) do
66
- double(
67
- body: [
68
- {
69
- "id": 10_001,
70
- "self": 'http://www.example.com/jira/rest/api/2.0/attachments/10000',
71
- "filename": 'picture.jpg',
72
- "created": '2017-07-19T12:23:06.572+0000',
73
- "size": 23_123,
74
- "mimeType": 'image/jpeg'
75
- }
76
- ].to_json
62
+ context 'there is an attachment on an issue' do
63
+ subject(:attachment) do
64
+ described_class.new(
65
+ client,
66
+ issue: JIRA::Resource::Issue.new(client),
67
+ attrs: { 'author' => { 'foo' => 'bar' }, 'content' => attachment_url }
77
68
  )
78
69
  end
79
- let(:issue) { JIRA::Resource::Issue.new(client) }
70
+
71
+ let(:client) do
72
+ JIRA::Client.new(username: 'username', password: 'password', auth_type: :basic, use_ssl: false)
73
+ end
74
+ let(:attachment_file_contents) { 'file contents' }
75
+ let(:attachment_url) { 'https://localhost:2990/secure/attachment/32323/myfile.txt' }
80
76
 
81
77
  before do
82
- allow(client).to receive(:post_multipart).and_return(response)
78
+ stub_request(:get, attachment_url).to_return(body: attachment_file_contents)
83
79
  end
84
80
 
85
- it 'successfully update the attachment' do
86
- subject
81
+ describe '.download_file' do
82
+ it 'passes file object to block' do
83
+ expect(URI).to receive(:parse).with(attachment_url).and_call_original
87
84
 
88
- expect(attachment.filename).to eq 'picture.jpg'
89
- expect(attachment.mimeType).to eq 'image/jpeg'
90
- expect(attachment.size).to eq 23_123
85
+ attachment.download_file do |file|
86
+ expect(file.read).to eq(attachment_file_contents)
87
+ end
88
+ end
91
89
  end
92
- end
93
90
 
94
- describe '#save!' do
95
- subject { attachment.save!('file' => path_to_file) }
91
+ describe '.download_contents' do
92
+ it 'downloads the file contents as a string' do
93
+ expect(URI).to receive(:parse).with(attachment_url).and_call_original
94
+ expect(attachment.download_contents).to eq(attachment_file_contents)
95
+ end
96
+ end
97
+ end
96
98
 
97
- let(:path_to_file) { './spec/mock_responses/issue.json' }
99
+ context 'when there is a local file' do
100
+ let(:file_name) { 'short.txt' }
101
+ let(:file_size) { 11 }
102
+ let(:file_mime_type) { 'text/plain' }
103
+ let(:path_to_file) { "./spec/data/files/#{file_name}" }
98
104
  let(:response) do
99
105
  double(
100
106
  body: [
101
107
  {
102
- "id": 10_001,
103
- "self": 'http://www.example.com/jira/rest/api/2.0/attachments/10000',
104
- "filename": 'picture.jpg',
105
- "created": '2017-07-19T12:23:06.572+0000',
106
- "size": 23_123,
107
- "mimeType": 'image/jpeg'
108
+ id: 10_001,
109
+ self: 'http://www.example.com/jira/rest/api/2.0/attachments/10000',
110
+ filename: file_name,
111
+ created: '2017-07-19T12:23:06.572+0000',
112
+ size: file_size,
113
+ mimeType: file_mime_type
108
114
  }
109
115
  ].to_json
110
116
  )
111
117
  end
112
118
  let(:issue) { JIRA::Resource::Issue.new(client) }
113
119
 
114
- before do
115
- allow(client).to receive(:post_multipart).and_return(response)
116
- end
120
+ describe '#save' do
121
+ subject { attachment.save('file' => path_to_file) }
117
122
 
118
- it 'successfully update the attachment' do
119
- subject
123
+ before do
124
+ allow(client).to receive(:post_multipart).and_return(response)
125
+ end
126
+
127
+ it 'successfully update the attachment' do
128
+ subject
120
129
 
121
- expect(attachment.filename).to eq 'picture.jpg'
122
- expect(attachment.mimeType).to eq 'image/jpeg'
123
- expect(attachment.size).to eq 23_123
130
+ expect(attachment.filename).to eq file_name
131
+ expect(attachment.mimeType).to eq file_mime_type
132
+ expect(attachment.size).to eq file_size
133
+ end
134
+
135
+ context 'when using custom client headers' do
136
+ subject(:bearer_attachment) do
137
+ described_class.new(
138
+ bearer_client,
139
+ issue: JIRA::Resource::Issue.new(bearer_client),
140
+ attrs: { 'author' => { 'foo' => 'bar' } }
141
+ )
142
+ end
143
+
144
+ let(:default_headers_given) do
145
+ {
146
+ 'authorization' => 'Bearer 83CF8B609DE60036A8277BD0E96135751BBC07EB234256D4B65B893360651BF2'
147
+ }
148
+ end
149
+ let(:bearer_client) do
150
+ JIRA::Client.new(username: 'username', password: 'password', auth_type: :basic, use_ssl: false,
151
+ default_headers: default_headers_given)
152
+ end
153
+ let(:merged_headers) do
154
+ {
155
+ 'Accept' => 'application/json',
156
+ 'X-Atlassian-Token' => 'nocheck'
157
+ }.merge(default_headers_given)
158
+ end
159
+
160
+ it 'passes the custom headers' do
161
+ expect(bearer_client.request_client).to receive(:request_multipart)
162
+ .with(anything, anything, merged_headers)
163
+ .and_return(response)
164
+
165
+ bearer_attachment.save('file' => path_to_file)
166
+ end
167
+ end
124
168
  end
125
169
 
126
- context 'when passing in a symbol as file key' do
127
- subject { attachment.save!(file: path_to_file) }
170
+ describe '#save!' do
171
+ subject { attachment.save!('file' => path_to_file) }
172
+
173
+ before do
174
+ allow(client).to receive(:post_multipart).and_return(response)
175
+ end
128
176
 
129
177
  it 'successfully update the attachment' do
130
178
  subject
131
179
 
132
- expect(attachment.filename).to eq 'picture.jpg'
133
- expect(attachment.mimeType).to eq 'image/jpeg'
134
- expect(attachment.size).to eq 23_123
180
+ expect(attachment.filename).to eq file_name
181
+ expect(attachment.mimeType).to eq file_mime_type
182
+ expect(attachment.size).to eq file_size
183
+ end
184
+
185
+ context 'when passing in a symbol as file key' do
186
+ subject { attachment.save!(file: path_to_file) }
187
+
188
+ it 'successfully update the attachment' do
189
+ subject
190
+
191
+ expect(attachment.filename).to eq file_name
192
+ expect(attachment.mimeType).to eq file_mime_type
193
+ expect(attachment.size).to eq file_size
194
+ end
195
+ end
196
+
197
+ context 'when using custom client headers' do
198
+ subject(:bearer_attachment) do
199
+ described_class.new(
200
+ bearer_client,
201
+ issue: JIRA::Resource::Issue.new(bearer_client),
202
+ attrs: { 'author' => { 'foo' => 'bar' } }
203
+ )
204
+ end
205
+
206
+ let(:default_headers_given) { { 'authorization' => 'Bearer 83CF8B609DE60036A8277BD0E96135751BBC07EB234256D4B65B893360651BF2' } }
207
+ let(:bearer_client) do
208
+ JIRA::Client.new(username: 'username', password: 'password', auth_type: :basic, use_ssl: false,
209
+ default_headers: default_headers_given)
210
+ end
211
+ let(:merged_headers) do
212
+ {
213
+ 'Accept' => 'application/json',
214
+ 'X-Atlassian-Token' => 'nocheck'
215
+ }.merge(default_headers_given)
216
+ end
217
+
218
+ it 'passes the custom headers' do
219
+ expect(bearer_client.request_client).to receive(:request_multipart)
220
+ .with(anything, anything, merged_headers)
221
+ .and_return(response)
222
+
223
+ bearer_attachment.save!('file' => path_to_file)
224
+ end
135
225
  end
136
226
  end
137
227
  end
@@ -21,16 +21,16 @@ describe JIRA::Resource::Board do
21
21
  \"type\": \"scrum\"
22
22
  }"
23
23
  allow(response).to receive(:body).and_return(api_json_board)
24
- expect(client).to receive(:get).with('/rest/agile/1.0/board/84')
25
- .and_return(response)
24
+ allow(client).to receive(:get).with('/rest/agile/1.0/board/84')
25
+ .and_return(response)
26
26
 
27
- expect(client).to receive(:Board).and_return(JIRA::Resource::BoardFactory.new(client))
28
- JIRA::Resource::Board.find(client, '84')
27
+ allow(client).to receive(:Board).and_return(JIRA::Resource::BoardFactory.new(client))
28
+ described_class.find(client, '84')
29
29
  end
30
30
 
31
- it 'should find all boards' do
31
+ it 'finds all boards' do
32
32
  response = double
33
- api_json = <<eos
33
+ api_json = <<EOS
34
34
  {
35
35
  "maxResults": 50,
36
36
  "startAt": 0,
@@ -48,24 +48,24 @@ describe JIRA::Resource::Board do
48
48
  }
49
49
  ]
50
50
  }
51
- eos
51
+ EOS
52
52
  allow(response).to receive(:body).and_return(api_json)
53
53
  expect(client).to receive(:get).with('/rest/agile/1.0/board')
54
54
  .and_return(response)
55
55
  expect(client).to receive(:Board).twice.and_return(JIRA::Resource::BoardFactory.new(client))
56
- boards = JIRA::Resource::Board.all(client)
56
+ boards = described_class.all(client)
57
57
  expect(boards.count).to eq(2)
58
58
  end
59
59
 
60
- it 'should find one board by id' do
61
- expect(board).to be_a(JIRA::Resource::Board)
60
+ it 'finds one board by id' do
61
+ expect(board).to be_a(described_class)
62
62
  end
63
63
 
64
64
  describe '#issues' do
65
- it 'should find all issues' do
65
+ it 'finds all issues' do
66
66
  issues_response = double
67
67
 
68
- api_json_issues = <<eos
68
+ api_json_issues = <<EOS
69
69
  {
70
70
  "expand": "names,schema",
71
71
  "startAt": 0,
@@ -85,7 +85,7 @@ eos
85
85
  }
86
86
  ]
87
87
  }
88
- eos
88
+ EOS
89
89
 
90
90
  allow(issues_response).to receive(:body).and_return(api_json_issues)
91
91
  allow(board).to receive(:id).and_return(84)
@@ -98,6 +98,7 @@ eos
98
98
 
99
99
  describe 'pagination' do
100
100
  subject { described_class.new(client) }
101
+
101
102
  let(:client) { JIRA::Client.new }
102
103
 
103
104
  before do
@@ -147,10 +148,10 @@ eos
147
148
  end
148
149
  end
149
150
 
150
- it 'should get all sprints for a board' do
151
+ it 'gets all sprints for a board' do
151
152
  response = double
152
153
 
153
- api_json = <<-eos
154
+ api_json = <<-EOS
154
155
  {
155
156
  "values": [
156
157
  {
@@ -165,7 +166,7 @@ eos
165
166
  }
166
167
  ]
167
168
  }
168
- eos
169
+ EOS
169
170
  allow(response).to receive(:body).and_return(api_json)
170
171
  allow(board).to receive(:id).and_return(84)
171
172
  expect(client).to receive(:get).with('/rest/agile/1.0/board/84/sprint?').and_return(response)
@@ -173,10 +174,10 @@ eos
173
174
  expect(board.sprints.size).to be(2)
174
175
  end
175
176
 
176
- it 'should get board configuration for a board' do
177
+ it 'gets board configuration for a board' do
177
178
  response = double
178
179
 
179
- api_json = <<-eos
180
+ api_json = <<-EOS
180
181
  {
181
182
  "id":1,
182
183
  "name":"My Board",
@@ -214,11 +215,11 @@ eos
214
215
  "rankCustomFieldId":10011
215
216
  }
216
217
  }
217
- eos
218
+ EOS
218
219
  allow(response).to receive(:body).and_return(api_json)
219
220
  allow(board).to receive(:id).and_return(84)
220
221
  expect(client).to receive(:get).with('/rest/agile/1.0/board/84/configuration').and_return(response)
221
222
  expect(client).to receive(:BoardConfiguration).and_return(JIRA::Resource::BoardConfigurationFactory.new(client))
222
- expect(board.configuration).not_to be(nil)
223
+ expect(board.configuration).not_to be_nil
223
224
  end
224
225
  end
@@ -18,24 +18,24 @@ describe JIRA::Resource::Createmeta do
18
18
  end
19
19
 
20
20
  describe 'general' do
21
- it 'should query correct url without parameters' do
21
+ it 'queries correct url without parameters' do
22
22
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta').and_return(response)
23
- JIRA::Resource::Createmeta.all(client)
23
+ described_class.all(client)
24
24
  end
25
25
 
26
- it 'should query correct url with `expand` parameter' do
26
+ it 'queries correct url with `expand` parameter' do
27
27
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?expand=projects.issuetypes.fields').and_return(response)
28
- JIRA::Resource::Createmeta.all(client, expand: 'projects.issuetypes.fields')
28
+ described_class.all(client, expand: 'projects.issuetypes.fields')
29
29
  end
30
30
 
31
- it 'should query correct url with `foo` parameter' do
31
+ it 'queries correct url with `foo` parameter' do
32
32
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?foo=bar').and_return(response)
33
- JIRA::Resource::Createmeta.all(client, foo: 'bar')
33
+ described_class.all(client, foo: 'bar')
34
34
  end
35
35
 
36
- it 'should return an array of createmeta objects' do
36
+ it 'returns an array of createmeta objects' do
37
37
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta').and_return(response)
38
- createmetas = JIRA::Resource::Createmeta.all(client)
38
+ createmetas = described_class.all(client)
39
39
  expect(createmetas).to be_an Array
40
40
  createmeta = createmetas.first
41
41
  expect(createmeta.id).to eq '10200'
@@ -45,52 +45,52 @@ describe JIRA::Resource::Createmeta do
45
45
  end
46
46
 
47
47
  describe 'projectKeys' do
48
- it 'should query correct url when only one `projectKeys` given as string' do
48
+ it 'queries correct url when only one `projectKeys` given as string' do
49
49
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectKeys=PROJECT_1').and_return(response)
50
- JIRA::Resource::Createmeta.all(
50
+ described_class.all(
51
51
  client,
52
52
  projectKeys: 'PROJECT_1'
53
53
  )
54
54
  end
55
55
 
56
- it 'should query correct url when multiple `projectKeys` given as string' do
56
+ it 'queries correct url when multiple `projectKeys` given as string' do
57
57
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectKeys=PROJECT_1%2CPROJECT_2').and_return(response)
58
- JIRA::Resource::Createmeta.all(
58
+ described_class.all(
59
59
  client,
60
60
  projectKeys: %w[PROJECT_1 PROJECT_2]
61
61
  )
62
62
  end
63
63
 
64
- it 'should query correct url when only one `projectKeys` given as Project' do
64
+ it 'queries correct url when only one `projectKeys` given as Project' do
65
65
  prj = JIRA::Resource::Project.new(client)
66
66
  allow(prj).to receive(:key).and_return('PRJ')
67
67
 
68
68
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectKeys=PRJ').and_return(response)
69
- JIRA::Resource::Createmeta.all(
69
+ described_class.all(
70
70
  client,
71
71
  projectKeys: prj
72
72
  )
73
73
  end
74
74
 
75
- it 'should query correct url when multiple `projectKeys` given as Project' do
75
+ it 'queries correct url when multiple `projectKeys` given as Project' do
76
76
  prj_1 = JIRA::Resource::Project.new(client)
77
77
  allow(prj_1).to receive(:key).and_return('PRJ_1')
78
78
  prj_2 = JIRA::Resource::Project.new(client)
79
79
  allow(prj_2).to receive(:key).and_return('PRJ_2')
80
80
 
81
81
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectKeys=PRJ_2%2CPRJ_1').and_return(response)
82
- JIRA::Resource::Createmeta.all(
82
+ described_class.all(
83
83
  client,
84
84
  projectKeys: [prj_2, prj_1]
85
85
  )
86
86
  end
87
87
 
88
- it 'should query correct url when multiple `projectKeys` given as different types' do
88
+ it 'queries correct url when multiple `projectKeys` given as different types' do
89
89
  prj_5 = JIRA::Resource::Project.new(client)
90
90
  allow(prj_5).to receive(:key).and_return('PRJ_5')
91
91
 
92
92
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectKeys=PROJECT_1%2CPRJ_5').and_return(response)
93
- JIRA::Resource::Createmeta.all(
93
+ described_class.all(
94
94
  client,
95
95
  projectKeys: ['PROJECT_1', prj_5]
96
96
  )
@@ -98,52 +98,52 @@ describe JIRA::Resource::Createmeta do
98
98
  end
99
99
 
100
100
  describe 'projectIds' do
101
- it 'should query correct url when only one `projectIds` given as string' do
101
+ it 'queries correct url when only one `projectIds` given as string' do
102
102
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectIds=10101').and_return(response)
103
- JIRA::Resource::Createmeta.all(
103
+ described_class.all(
104
104
  client,
105
105
  projectIds: '10101'
106
106
  )
107
107
  end
108
108
 
109
- it 'should query correct url when multiple `projectIds` given as string' do
109
+ it 'queries correct url when multiple `projectIds` given as string' do
110
110
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectIds=10101%2C20202').and_return(response)
111
- JIRA::Resource::Createmeta.all(
111
+ described_class.all(
112
112
  client,
113
113
  projectIds: %w[10101 20202]
114
114
  )
115
115
  end
116
116
 
117
- it 'should query correct url when only one `projectIds` given as Project' do
117
+ it 'queries correct url when only one `projectIds` given as Project' do
118
118
  prj = JIRA::Resource::Project.new(client)
119
119
  allow(prj).to receive(:id).and_return('30303')
120
120
 
121
121
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectIds=30303').and_return(response)
122
- JIRA::Resource::Createmeta.all(
122
+ described_class.all(
123
123
  client,
124
124
  projectIds: prj
125
125
  )
126
126
  end
127
127
 
128
- it 'should query correct url when multiple `projectIds` given as Project' do
128
+ it 'queries correct url when multiple `projectIds` given as Project' do
129
129
  prj_1 = JIRA::Resource::Project.new(client)
130
130
  allow(prj_1).to receive(:id).and_return('30303')
131
131
  prj_2 = JIRA::Resource::Project.new(client)
132
132
  allow(prj_2).to receive(:id).and_return('50505')
133
133
 
134
134
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectIds=50505%2C30303').and_return(response)
135
- JIRA::Resource::Createmeta.all(
135
+ described_class.all(
136
136
  client,
137
137
  projectIds: [prj_2, prj_1]
138
138
  )
139
139
  end
140
140
 
141
- it 'should query correct url when multiple `projectIds` given as different types' do
141
+ it 'queries correct url when multiple `projectIds` given as different types' do
142
142
  prj_5 = JIRA::Resource::Project.new(client)
143
143
  allow(prj_5).to receive(:id).and_return('60606')
144
144
 
145
145
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectIds=10101%2C60606').and_return(response)
146
- JIRA::Resource::Createmeta.all(
146
+ described_class.all(
147
147
  client,
148
148
  projectIds: ['10101', prj_5]
149
149
  )
@@ -151,52 +151,52 @@ describe JIRA::Resource::Createmeta do
151
151
  end
152
152
 
153
153
  describe 'issuetypeNames' do
154
- it 'should query correct url when only one `issuetypeNames` given as string' do
154
+ it 'queries correct url when only one `issuetypeNames` given as string' do
155
155
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeNames=Feature').and_return(response)
156
- JIRA::Resource::Createmeta.all(
156
+ described_class.all(
157
157
  client,
158
158
  issuetypeNames: 'Feature'
159
159
  )
160
160
  end
161
161
 
162
- it 'should query correct url when multiple `issuetypeNames` given as string' do
162
+ it 'queries correct url when multiple `issuetypeNames` given as string' do
163
163
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeNames=Feature%2CBug').and_return(response)
164
- JIRA::Resource::Createmeta.all(
164
+ described_class.all(
165
165
  client,
166
166
  issuetypeNames: %w[Feature Bug]
167
167
  )
168
168
  end
169
169
 
170
- it 'should query correct url when only one `issuetypeNames` given as Issuetype' do
170
+ it 'queries correct url when only one `issuetypeNames` given as Issuetype' do
171
171
  issue_type = JIRA::Resource::Issuetype.new(client)
172
172
  allow(issue_type).to receive(:name).and_return('Epic')
173
173
 
174
174
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeNames=Epic').and_return(response)
175
- JIRA::Resource::Createmeta.all(
175
+ described_class.all(
176
176
  client,
177
177
  issuetypeNames: issue_type
178
178
  )
179
179
  end
180
180
 
181
- it 'should query correct url when multiple `issuetypeNames` given as Issuetype' do
181
+ it 'queries correct url when multiple `issuetypeNames` given as Issuetype' do
182
182
  issue_type_1 = JIRA::Resource::Issuetype.new(client)
183
183
  allow(issue_type_1).to receive(:name).and_return('Epic')
184
184
  issue_type_2 = JIRA::Resource::Issuetype.new(client)
185
185
  allow(issue_type_2).to receive(:name).and_return('Sub-Task')
186
186
 
187
187
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeNames=Sub-Task%2CEpic').and_return(response)
188
- JIRA::Resource::Createmeta.all(
188
+ described_class.all(
189
189
  client,
190
190
  issuetypeNames: [issue_type_2, issue_type_1]
191
191
  )
192
192
  end
193
193
 
194
- it 'should query correct url when multiple `issuetypeNames` given as different types' do
194
+ it 'queries correct url when multiple `issuetypeNames` given as different types' do
195
195
  issue_type = JIRA::Resource::Issuetype.new(client)
196
196
  allow(issue_type).to receive(:name).and_return('Epic')
197
197
 
198
198
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeNames=Feature%2CEpic').and_return(response)
199
- JIRA::Resource::Createmeta.all(
199
+ described_class.all(
200
200
  client,
201
201
  issuetypeNames: ['Feature', issue_type]
202
202
  )
@@ -204,52 +204,52 @@ describe JIRA::Resource::Createmeta do
204
204
  end
205
205
 
206
206
  describe 'issuetypeIds' do
207
- it 'should query correct url when only one `issuetypeIds` given as string' do
207
+ it 'queries correct url when only one `issuetypeIds` given as string' do
208
208
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeIds=10101').and_return(response)
209
- JIRA::Resource::Createmeta.all(
209
+ described_class.all(
210
210
  client,
211
211
  issuetypeIds: '10101'
212
212
  )
213
213
  end
214
214
 
215
- it 'should query correct url when multiple `issuetypeIds` given as string' do
215
+ it 'queries correct url when multiple `issuetypeIds` given as string' do
216
216
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeIds=10101%2C20202').and_return(response)
217
- JIRA::Resource::Createmeta.all(
217
+ described_class.all(
218
218
  client,
219
219
  issuetypeIds: %w[10101 20202]
220
220
  )
221
221
  end
222
222
 
223
- it 'should query correct url when only one `issuetypeIds` given as Issuetype' do
223
+ it 'queries correct url when only one `issuetypeIds` given as Issuetype' do
224
224
  issue_type = JIRA::Resource::Issuetype.new(client)
225
225
  allow(issue_type).to receive(:id).and_return('30303')
226
226
 
227
227
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeIds=30303').and_return(response)
228
- JIRA::Resource::Createmeta.all(
228
+ described_class.all(
229
229
  client,
230
230
  issuetypeIds: issue_type
231
231
  )
232
232
  end
233
233
 
234
- it 'should query correct url when multiple `issuetypeIds` given as Issuetype' do
234
+ it 'queries correct url when multiple `issuetypeIds` given as Issuetype' do
235
235
  issue_type_1 = JIRA::Resource::Issuetype.new(client)
236
236
  allow(issue_type_1).to receive(:id).and_return('30303')
237
237
  issue_type_2 = JIRA::Resource::Issuetype.new(client)
238
238
  allow(issue_type_2).to receive(:id).and_return('50505')
239
239
 
240
240
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeIds=50505%2C30303').and_return(response)
241
- JIRA::Resource::Createmeta.all(
241
+ described_class.all(
242
242
  client,
243
243
  issuetypeIds: [issue_type_2, issue_type_1]
244
244
  )
245
245
  end
246
246
 
247
- it 'should query correct url when multiple `issuetypeIds` given as different types' do
247
+ it 'queries correct url when multiple `issuetypeIds` given as different types' do
248
248
  issue_type = JIRA::Resource::Issuetype.new(client)
249
249
  allow(issue_type).to receive(:id).and_return('30303')
250
250
 
251
251
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?issuetypeIds=10101%2C30303').and_return(response)
252
- JIRA::Resource::Createmeta.all(
252
+ described_class.all(
253
253
  client,
254
254
  issuetypeIds: ['10101', issue_type]
255
255
  )