jira-ruby 2.2.0 → 3.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +20 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/CI.yml +28 -0
- data/.github/workflows/codeql.yml +100 -0
- data/.github/workflows/rubocop.yml +18 -0
- data/.rubocop.yml +188 -0
- data/Gemfile +11 -3
- data/Guardfile +2 -0
- data/README.md +121 -20
- data/Rakefile +4 -5
- data/jira-ruby.gemspec +11 -17
- data/lib/jira/base.rb +37 -28
- data/lib/jira/base_factory.rb +4 -1
- data/lib/jira/client.rb +65 -46
- data/lib/jira/has_many_proxy.rb +4 -2
- data/lib/jira/http_client.rb +18 -13
- data/lib/jira/http_error.rb +4 -0
- data/lib/jira/jwt_client.rb +18 -42
- data/lib/jira/oauth_client.rb +6 -3
- data/lib/jira/railtie.rb +2 -0
- data/lib/jira/request_client.rb +5 -1
- data/lib/jira/resource/agile.rb +7 -9
- data/lib/jira/resource/applinks.rb +5 -3
- data/lib/jira/resource/attachment.rb +43 -3
- data/lib/jira/resource/board.rb +5 -3
- data/lib/jira/resource/board_configuration.rb +2 -0
- data/lib/jira/resource/comment.rb +2 -0
- data/lib/jira/resource/component.rb +2 -0
- data/lib/jira/resource/createmeta.rb +3 -1
- data/lib/jira/resource/field.rb +9 -4
- data/lib/jira/resource/filter.rb +2 -0
- data/lib/jira/resource/issue.rb +35 -44
- data/lib/jira/resource/issue_picker_suggestions.rb +4 -1
- data/lib/jira/resource/issue_picker_suggestions_issue.rb +2 -0
- data/lib/jira/resource/issuelink.rb +2 -0
- data/lib/jira/resource/issuelinktype.rb +2 -0
- data/lib/jira/resource/issuetype.rb +2 -0
- data/lib/jira/resource/priority.rb +2 -0
- data/lib/jira/resource/project.rb +4 -2
- data/lib/jira/resource/rapidview.rb +5 -3
- data/lib/jira/resource/remotelink.rb +2 -0
- data/lib/jira/resource/resolution.rb +2 -0
- data/lib/jira/resource/serverinfo.rb +2 -0
- data/lib/jira/resource/sprint.rb +14 -23
- data/lib/jira/resource/status.rb +7 -1
- data/lib/jira/resource/status_category.rb +10 -0
- data/lib/jira/resource/suggested_issue.rb +2 -0
- data/lib/jira/resource/transition.rb +2 -0
- data/lib/jira/resource/user.rb +3 -1
- data/lib/jira/resource/version.rb +2 -0
- data/lib/jira/resource/watcher.rb +2 -1
- data/lib/jira/resource/webhook.rb +4 -2
- data/lib/jira/resource/worklog.rb +3 -2
- data/lib/jira/version.rb +3 -1
- data/lib/jira-ruby.rb +5 -3
- data/lib/tasks/generate.rake +4 -2
- data/spec/data/files/short.txt +1 -0
- data/spec/integration/attachment_spec.rb +3 -3
- data/spec/integration/comment_spec.rb +8 -8
- data/spec/integration/component_spec.rb +7 -7
- data/spec/integration/field_spec.rb +3 -3
- data/spec/integration/issue_spec.rb +20 -16
- data/spec/integration/issuelinktype_spec.rb +3 -3
- data/spec/integration/issuetype_spec.rb +3 -3
- data/spec/integration/priority_spec.rb +3 -3
- data/spec/integration/project_spec.rb +7 -7
- data/spec/integration/rapidview_spec.rb +9 -9
- data/spec/integration/resolution_spec.rb +3 -3
- data/spec/integration/status_category_spec.rb +20 -0
- data/spec/integration/status_spec.rb +4 -8
- data/spec/integration/transition_spec.rb +2 -2
- data/spec/integration/user_spec.rb +22 -8
- data/spec/integration/version_spec.rb +7 -7
- data/spec/integration/watcher_spec.rb +17 -18
- data/spec/integration/webhook.rb +5 -4
- data/spec/integration/worklog_spec.rb +8 -8
- data/spec/jira/base_factory_spec.rb +2 -1
- data/spec/jira/base_spec.rb +55 -41
- data/spec/jira/client_spec.rb +48 -34
- data/spec/jira/has_many_proxy_spec.rb +3 -3
- data/spec/jira/http_client_spec.rb +98 -26
- data/spec/jira/http_error_spec.rb +2 -2
- data/spec/jira/oauth_client_spec.rb +30 -8
- data/spec/jira/request_client_spec.rb +4 -4
- data/spec/jira/resource/agile_spec.rb +28 -28
- data/spec/jira/resource/attachment_spec.rb +142 -52
- data/spec/jira/resource/board_spec.rb +21 -20
- data/spec/jira/resource/createmeta_spec.rb +48 -48
- data/spec/jira/resource/field_spec.rb +30 -12
- data/spec/jira/resource/filter_spec.rb +4 -4
- data/spec/jira/resource/issue_picker_suggestions_spec.rb +18 -18
- data/spec/jira/resource/issue_spec.rb +44 -38
- data/spec/jira/resource/jira_picker_suggestions_issue_spec.rb +3 -3
- data/spec/jira/resource/project_factory_spec.rb +3 -2
- data/spec/jira/resource/project_spec.rb +16 -16
- data/spec/jira/resource/sprint_spec.rb +70 -3
- data/spec/jira/resource/status_spec.rb +21 -0
- data/spec/jira/resource/user_factory_spec.rb +4 -4
- data/spec/jira/resource/worklog_spec.rb +3 -3
- data/spec/mock_responses/sprint/1.json +13 -0
- data/spec/mock_responses/status/1.json +8 -1
- data/spec/mock_responses/status.json +40 -5
- data/spec/mock_responses/statuscategory/1.json +7 -0
- data/spec/mock_responses/statuscategory.json +30 -0
- data/spec/mock_responses/{user_username=admin.json → user_accountId=1234567890abcdef01234567.json} +2 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/support/clients_helper.rb +3 -5
- data/spec/support/shared_examples/integration.rb +25 -28
- metadata +25 -257
- data/.travis.yml +0 -9
- data/example.rb +0 -232
- data/http-basic-example.rb +0 -113
- data/lib/jira/resource/sprint_report.rb +0 -8
- data/lib/jira/tasks.rb +0 -0
- data/spec/jira/jwt_uri_builder_spec.rb +0 -59
data/lib/jira/resource/user.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module JIRA
|
2
4
|
module Resource
|
3
5
|
class UserFactory < JIRA::BaseFactory # :nodoc:
|
@@ -13,7 +15,7 @@ module JIRA
|
|
13
15
|
MAX_RESULTS = 1000
|
14
16
|
|
15
17
|
def self.singular_path(client, key, prefix = '/')
|
16
|
-
collection_path(client, prefix)
|
18
|
+
"#{collection_path(client, prefix)}?accountId=#{key}"
|
17
19
|
end
|
18
20
|
|
19
21
|
# Cannot retrieve more than 1,000 users through the api, please see: https://jira.atlassian.com/browse/JRASERVER-65089
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module JIRA
|
2
4
|
module Resource
|
3
5
|
class WebhookFactory < JIRA::BaseFactory # :nodoc:
|
4
6
|
end
|
5
7
|
|
6
8
|
class Webhook < JIRA::Base
|
7
|
-
REST_BASE_PATH = '/rest/webhooks/1.0'
|
9
|
+
REST_BASE_PATH = '/rest/webhooks/1.0'
|
8
10
|
|
9
11
|
def self.endpoint_name
|
10
12
|
'webhook'
|
@@ -22,7 +24,7 @@ module JIRA
|
|
22
24
|
response = client.get(collection_path(client))
|
23
25
|
json = parse_json(response.body)
|
24
26
|
json.map do |attrs|
|
25
|
-
new(client, { attrs:
|
27
|
+
new(client, { attrs: }.merge(options))
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module JIRA
|
2
4
|
module Resource
|
3
5
|
class WorklogFactory < JIRA::BaseFactory # :nodoc:
|
@@ -5,8 +7,7 @@ module JIRA
|
|
5
7
|
|
6
8
|
class Worklog < JIRA::Base
|
7
9
|
has_one :author, class: JIRA::Resource::User
|
8
|
-
has_one :update_author, class: JIRA::Resource::User,
|
9
|
-
attribute_key: 'updateAuthor'
|
10
|
+
has_one :update_author, class: JIRA::Resource::User, attribute_key: 'updateAuthor'
|
10
11
|
belongs_to :issue
|
11
12
|
nested_collections true
|
12
13
|
end
|
data/lib/jira/version.rb
CHANGED
data/lib/jira-ruby.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
$LOAD_PATH << __dir__
|
2
4
|
|
3
5
|
require 'active_support'
|
4
6
|
require 'active_support/inflector'
|
5
7
|
ActiveSupport::Inflector.inflections do |inflector|
|
6
|
-
inflector.singular
|
8
|
+
inflector.singular(/status$/, 'status')
|
7
9
|
end
|
8
10
|
|
9
11
|
require 'jira/base'
|
@@ -18,6 +20,7 @@ require 'jira/resource/component'
|
|
18
20
|
require 'jira/resource/issuetype'
|
19
21
|
require 'jira/resource/version'
|
20
22
|
require 'jira/resource/status'
|
23
|
+
require 'jira/resource/status_category'
|
21
24
|
require 'jira/resource/transition'
|
22
25
|
require 'jira/resource/project'
|
23
26
|
require 'jira/resource/priority'
|
@@ -31,12 +34,11 @@ require 'jira/resource/issue_picker_suggestions_issue'
|
|
31
34
|
require 'jira/resource/issue_picker_suggestions'
|
32
35
|
require 'jira/resource/remotelink'
|
33
36
|
require 'jira/resource/sprint'
|
34
|
-
require 'jira/resource/
|
37
|
+
require 'jira/resource/resolution'
|
35
38
|
require 'jira/resource/issue'
|
36
39
|
require 'jira/resource/filter'
|
37
40
|
require 'jira/resource/field'
|
38
41
|
require 'jira/resource/rapidview'
|
39
|
-
require 'jira/resource/resolution'
|
40
42
|
require 'jira/resource/serverinfo'
|
41
43
|
require 'jira/resource/createmeta'
|
42
44
|
require 'jira/resource/webhook'
|
data/lib/tasks/generate.rake
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'securerandom'
|
2
4
|
|
3
5
|
namespace :jira do
|
@@ -10,8 +12,8 @@ namespace :jira do
|
|
10
12
|
desc 'Run the system call to generate a RSA public certificate'
|
11
13
|
task :generate_public_cert do
|
12
14
|
puts "Executing 'openssl req -x509 -nodes -newkey rsa:1024 -sha1 -keyout rsakey.pem -out rsacert.pem'"
|
13
|
-
system('openssl req -x509 -subj "/C=US/ST=New York/L=New York/O=SUMO Heavy Industries/CN=www.sumoheavy.com" -nodes -newkey rsa:1024 -sha1 -keyout rsakey.pem -out rsacert.pem')
|
14
|
-
puts "Done. The RSA-SHA1 private keyfile is in the current directory:
|
15
|
+
system('openssl req -x509 -subj "/C=US/ST=New York/L=New York/O=SUMO Heavy Industries/CN=www.sumoheavy.com" -nodes -newkey rsa:1024 -sha1 -keyout rsakey.pem -out rsacert.pem') # rubocop:disable Layout/LineLength
|
16
|
+
puts "Done. The RSA-SHA1 private keyfile is in the current directory: 'rsakey.pem'."
|
15
17
|
puts 'You will need to copy the following certificate into your application link configuration in Jira:'
|
16
18
|
system('cat rsacert.pem')
|
17
19
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
short text
|
@@ -7,7 +7,7 @@ describe JIRA::Resource::Attachment do
|
|
7
7
|
|
8
8
|
let(:key) { '10000' }
|
9
9
|
|
10
|
-
let(:target) {
|
10
|
+
let(:target) { described_class.new(client, attrs: { 'id' => '99999' }, issue_id: '10002') }
|
11
11
|
|
12
12
|
let(:expected_attributes) do
|
13
13
|
{
|
@@ -26,7 +26,7 @@ describe JIRA::Resource::Attachment do
|
|
26
26
|
})
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
it_behaves_like 'a resource with a singular GET endpoint'
|
30
|
+
it_behaves_like 'a resource with a DELETE endpoint'
|
31
31
|
end
|
32
32
|
end
|
@@ -7,7 +7,7 @@ describe JIRA::Resource::Comment do
|
|
7
7
|
|
8
8
|
let(:key) { '10000' }
|
9
9
|
|
10
|
-
let(:target) {
|
10
|
+
let(:target) { described_class.new(client, attrs: { 'id' => '99999' }, issue_id: '54321') }
|
11
11
|
|
12
12
|
let(:expected_collection_length) { 2 }
|
13
13
|
|
@@ -23,7 +23,7 @@ describe JIRA::Resource::Comment do
|
|
23
23
|
let(:expected_attributes) do
|
24
24
|
{
|
25
25
|
'self' => 'http://localhost:2990/jira/rest/api/2/issue/10002/comment/10000',
|
26
|
-
'id'
|
26
|
+
'id' => key,
|
27
27
|
'body' => 'This is a comment. Creative.'
|
28
28
|
}
|
29
29
|
end
|
@@ -42,11 +42,11 @@ describe JIRA::Resource::Comment do
|
|
42
42
|
{ 'id' => '10000', 'body' => 'new body' }
|
43
43
|
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
it_behaves_like 'a resource'
|
46
|
+
it_behaves_like 'a resource with a collection GET endpoint'
|
47
|
+
it_behaves_like 'a resource with a singular GET endpoint'
|
48
|
+
it_behaves_like 'a resource with a DELETE endpoint'
|
49
|
+
it_behaves_like 'a resource with a POST endpoint'
|
50
|
+
it_behaves_like 'a resource with a PUT endpoint'
|
51
51
|
end
|
52
52
|
end
|
@@ -10,7 +10,7 @@ describe JIRA::Resource::Component do
|
|
10
10
|
let(:expected_attributes) do
|
11
11
|
{
|
12
12
|
'self' => 'http://localhost:2990/jira/rest/api/2/component/10000',
|
13
|
-
'id'
|
13
|
+
'id' => key,
|
14
14
|
'name' => 'Cheesecake'
|
15
15
|
}
|
16
16
|
end
|
@@ -29,11 +29,11 @@ describe JIRA::Resource::Component do
|
|
29
29
|
{ 'id' => '10000', 'name' => 'Jammy' }
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
it_behaves_like 'a resource'
|
33
|
+
it_behaves_like 'a resource with a singular GET endpoint'
|
34
|
+
it_behaves_like 'a resource with a DELETE endpoint'
|
35
|
+
it_behaves_like 'a resource with a POST endpoint'
|
36
|
+
it_behaves_like 'a resource with a PUT endpoint'
|
37
|
+
it_behaves_like 'a resource with a PUT endpoint that rejects invalid fields'
|
38
38
|
end
|
39
39
|
end
|
@@ -25,8 +25,8 @@ describe JIRA::Resource::Field do
|
|
25
25
|
|
26
26
|
let(:expected_collection_length) { 2 }
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
it_behaves_like 'a resource'
|
29
|
+
it_behaves_like 'a resource with a collection GET endpoint'
|
30
|
+
it_behaves_like 'a resource with a singular GET endpoint'
|
31
31
|
end
|
32
32
|
end
|
@@ -9,8 +9,8 @@ describe JIRA::Resource::Issue do
|
|
9
9
|
|
10
10
|
let(:expected_attributes) do
|
11
11
|
{
|
12
|
-
'self'
|
13
|
-
'key'
|
12
|
+
'self' => 'http://localhost:2990/jira/rest/api/2/issue/10002',
|
13
|
+
'key' => 'SAMPLEPROJECT-1',
|
14
14
|
'expand' => 'renderedFields,names,schema,transitions,editmeta,changelog'
|
15
15
|
}
|
16
16
|
end
|
@@ -30,8 +30,8 @@ describe JIRA::Resource::Issue do
|
|
30
30
|
end
|
31
31
|
let(:expected_collection_length) { 11 }
|
32
32
|
|
33
|
-
|
34
|
-
|
33
|
+
it_behaves_like 'a resource'
|
34
|
+
it_behaves_like 'a resource with a singular GET endpoint'
|
35
35
|
describe 'GET all issues' do # JIRA::Resource::Issue.all uses the search endpoint
|
36
36
|
let(:client) { client }
|
37
37
|
let(:site_url) { site_url }
|
@@ -43,26 +43,29 @@ describe JIRA::Resource::Issue do
|
|
43
43
|
'key' => 'SAMPLEPROJECT-13'
|
44
44
|
}
|
45
45
|
end
|
46
|
-
|
47
|
-
|
46
|
+
|
47
|
+
before do
|
48
|
+
stub_request(:get, "#{site_url}/jira/rest/api/2/search?expand=transitions.fields&maxResults=1000&startAt=0")
|
48
49
|
.to_return(status: 200, body: get_mock_response('issue.json'))
|
49
50
|
|
50
|
-
stub_request(:get, site_url
|
51
|
+
stub_request(:get, "#{site_url}/jira/rest/api/2/search?expand=transitions.fields&maxResults=1000&startAt=11")
|
51
52
|
.to_return(status: 200, body: get_mock_response('empty_issues.json'))
|
52
53
|
end
|
53
|
-
|
54
|
+
|
55
|
+
it_behaves_like 'a resource with a collection GET endpoint'
|
54
56
|
end
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
|
58
|
+
it_behaves_like 'a resource with a DELETE endpoint'
|
59
|
+
it_behaves_like 'a resource with a POST endpoint'
|
60
|
+
it_behaves_like 'a resource with a PUT endpoint'
|
61
|
+
it_behaves_like 'a resource with a PUT endpoint that rejects invalid fields'
|
59
62
|
|
60
63
|
describe 'errors' do
|
61
|
-
before
|
64
|
+
before do
|
62
65
|
stub_request(:get,
|
63
|
-
site_url
|
66
|
+
"#{site_url}/jira/rest/api/2/issue/10002")
|
64
67
|
.to_return(status: 200, body: get_mock_response('issue/10002.json'))
|
65
|
-
stub_request(:put, site_url
|
68
|
+
stub_request(:put, "#{site_url}/jira/rest/api/2/issue/10002")
|
66
69
|
.with(body: '{"missing":"fields and update"}')
|
67
70
|
.to_return(status: 400, body: get_mock_response('issue/10002.put.missing_field_update.json'))
|
68
71
|
end
|
@@ -87,7 +90,8 @@ describe JIRA::Resource::Issue do
|
|
87
90
|
'key' => 'SAMPLEPROJECT-13'
|
88
91
|
}
|
89
92
|
end
|
90
|
-
|
93
|
+
|
94
|
+
it_behaves_like 'a resource with JQL inputs and a collection GET endpoint'
|
91
95
|
end
|
92
96
|
end
|
93
97
|
end
|
@@ -19,8 +19,8 @@ describe JIRA::Resource::Issuelinktype do
|
|
19
19
|
|
20
20
|
let(:expected_collection_length) { 3 }
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
it_behaves_like 'a resource'
|
23
|
+
it_behaves_like 'a resource with a collection GET endpoint'
|
24
|
+
it_behaves_like 'a resource with a singular GET endpoint'
|
25
25
|
end
|
26
26
|
end
|
@@ -17,8 +17,8 @@ describe JIRA::Resource::Issuetype do
|
|
17
17
|
|
18
18
|
let(:expected_collection_length) { 5 }
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
it_behaves_like 'a resource'
|
21
|
+
it_behaves_like 'a resource with a collection GET endpoint'
|
22
|
+
it_behaves_like 'a resource with a singular GET endpoint'
|
23
23
|
end
|
24
24
|
end
|
@@ -17,8 +17,8 @@ describe JIRA::Resource::Priority do
|
|
17
17
|
|
18
18
|
let(:expected_collection_length) { 5 }
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
it_behaves_like 'a resource'
|
21
|
+
it_behaves_like 'a resource with a collection GET endpoint'
|
22
|
+
it_behaves_like 'a resource with a singular GET endpoint'
|
23
23
|
end
|
24
24
|
end
|
@@ -9,21 +9,21 @@ describe JIRA::Resource::Project do
|
|
9
9
|
|
10
10
|
let(:expected_attributes) do
|
11
11
|
{
|
12
|
-
'self'
|
13
|
-
'key'
|
14
|
-
'name'
|
12
|
+
'self' => 'http://localhost:2990/jira/rest/api/2/project/SAMPLEPROJECT',
|
13
|
+
'key' => key,
|
14
|
+
'name' => 'Sample Project for Developing RoR RESTful API'
|
15
15
|
}
|
16
16
|
end
|
17
17
|
|
18
18
|
let(:expected_collection_length) { 1 }
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
it_behaves_like 'a resource'
|
21
|
+
it_behaves_like 'a resource with a collection GET endpoint'
|
22
|
+
it_behaves_like 'a resource with a singular GET endpoint'
|
23
23
|
|
24
24
|
describe 'issues' do
|
25
25
|
it 'returns all the issues' do
|
26
|
-
stub_request(:get, site_url
|
26
|
+
stub_request(:get, "#{site_url}/jira/rest/api/2/search?jql=project=\"SAMPLEPROJECT\"")
|
27
27
|
.to_return(status: 200, body: get_mock_response('project/SAMPLEPROJECT.issues.json'))
|
28
28
|
subject = client.Project.build('key' => key)
|
29
29
|
issues = subject.issues
|
@@ -18,7 +18,7 @@ describe JIRA::Resource::RapidView do
|
|
18
18
|
}
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
it_behaves_like 'a resource'
|
22
22
|
# TODO@Anton: Add json file
|
23
23
|
# it_should_behave_like 'a resource with a singular GET endpoint'
|
24
24
|
|
@@ -26,19 +26,19 @@ describe JIRA::Resource::RapidView do
|
|
26
26
|
let(:client) { client }
|
27
27
|
let(:site_url) { site_url }
|
28
28
|
|
29
|
-
before
|
30
|
-
stub_request(:get, site_url
|
29
|
+
before do
|
30
|
+
stub_request(:get, "#{site_url}/jira/rest/greenhopper/1.0/rapidview")
|
31
31
|
.to_return(status: 200, body: get_mock_response('rapidview.json'))
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
|
+
it_behaves_like 'a resource with a collection GET endpoint'
|
34
35
|
end
|
35
36
|
|
36
37
|
describe 'issues' do
|
37
|
-
it '
|
38
|
+
it 'returns all the issues' do
|
38
39
|
stub_request(
|
39
40
|
:get,
|
40
|
-
site_url
|
41
|
-
'/jira/rest/greenhopper/1.0/xboard/plan/backlog/data?rapidViewId=1'
|
41
|
+
"#{site_url}/jira/rest/greenhopper/1.0/xboard/plan/backlog/data?rapidViewId=1"
|
42
42
|
).to_return(
|
43
43
|
status: 200,
|
44
44
|
body: get_mock_response('rapidview/SAMPLEPROJECT.issues.json')
|
@@ -46,7 +46,7 @@ describe JIRA::Resource::RapidView do
|
|
46
46
|
|
47
47
|
stub_request(
|
48
48
|
:get,
|
49
|
-
site_url
|
49
|
+
"#{site_url}/jira/rest/api/2/search?jql=id IN(10001, 10000)"
|
50
50
|
).to_return(
|
51
51
|
status: 200,
|
52
52
|
body: get_mock_response('rapidview/SAMPLEPROJECT.issues.full.json')
|
@@ -54,7 +54,7 @@ describe JIRA::Resource::RapidView do
|
|
54
54
|
|
55
55
|
stub_request(
|
56
56
|
:get,
|
57
|
-
site_url
|
57
|
+
"#{site_url}/jira/rest/api/2/search?jql=id IN(10000, 10001) AND sprint IS NOT EMPTY"
|
58
58
|
).to_return(
|
59
59
|
status: 200,
|
60
60
|
body: get_mock_response('rapidview/SAMPLEPROJECT.issues.full.json')
|
@@ -19,8 +19,8 @@ describe JIRA::Resource::Resolution do
|
|
19
19
|
|
20
20
|
let(:expected_collection_length) { 2 }
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
it_behaves_like 'a resource'
|
23
|
+
it_behaves_like 'a resource with a collection GET endpoint'
|
24
|
+
it_behaves_like 'a resource with a singular GET endpoint'
|
25
25
|
end
|
26
26
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::StatusCategory do
|
4
|
+
with_each_client do |site_url, client|
|
5
|
+
let(:client) { client }
|
6
|
+
let(:site_url) { site_url }
|
7
|
+
|
8
|
+
let(:key) { 1 }
|
9
|
+
|
10
|
+
let(:expected_attributes) do
|
11
|
+
JSON.parse(File.read('spec/mock_responses/statuscategory/1.json'))
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:expected_collection_length) { 4 }
|
15
|
+
|
16
|
+
it_behaves_like 'a resource'
|
17
|
+
it_behaves_like 'a resource with a collection GET endpoint'
|
18
|
+
it_behaves_like 'a resource with a singular GET endpoint'
|
19
|
+
end
|
20
|
+
end
|
@@ -8,17 +8,13 @@ describe JIRA::Resource::Status do
|
|
8
8
|
let(:key) { '1' }
|
9
9
|
|
10
10
|
let(:expected_attributes) do
|
11
|
-
|
12
|
-
'self' => 'http://localhost:2990/jira/rest/api/2/status/1',
|
13
|
-
'id' => key,
|
14
|
-
'name' => 'Open'
|
15
|
-
}
|
11
|
+
JSON.parse(File.read('spec/mock_responses/status/1.json'))
|
16
12
|
end
|
17
13
|
|
18
14
|
let(:expected_collection_length) { 5 }
|
19
15
|
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
it_behaves_like 'a resource'
|
17
|
+
it_behaves_like 'a resource with a collection GET endpoint'
|
18
|
+
it_behaves_like 'a resource with a singular GET endpoint'
|
23
19
|
end
|
24
20
|
end
|
@@ -7,7 +7,7 @@ describe JIRA::Resource::Transition do
|
|
7
7
|
|
8
8
|
let(:key) { '10000' }
|
9
9
|
|
10
|
-
let(:target) {
|
10
|
+
let(:target) { described_class.new(client, attrs: { 'id' => '99999' }, issue_id: '10014') }
|
11
11
|
|
12
12
|
let(:belongs_to) do
|
13
13
|
JIRA::Resource::Issue.new(client, attrs: {
|
@@ -34,7 +34,7 @@ describe JIRA::Resource::Transition do
|
|
34
34
|
}
|
35
35
|
end
|
36
36
|
|
37
|
-
|
37
|
+
it_behaves_like 'a resource'
|
38
38
|
|
39
39
|
describe 'POST endpoint' do
|
40
40
|
it 'saves a new resource' do
|
@@ -5,23 +5,37 @@ describe JIRA::Resource::User do
|
|
5
5
|
let(:client) { client }
|
6
6
|
let(:site_url) { site_url }
|
7
7
|
|
8
|
-
let(:key) { '
|
8
|
+
let(:key) { '1234567890abcdef01234567' }
|
9
9
|
|
10
10
|
let(:expected_attributes) do
|
11
11
|
{
|
12
|
-
'
|
13
|
-
'
|
14
|
-
'
|
12
|
+
'id' => '1234567890abcdef01234567',
|
13
|
+
'self' => 'http://localhost:2990/jira/rest/api/2/user?accountId=1234567890abcdef01234567',
|
14
|
+
'name' => 'admin',
|
15
|
+
'emailAddress' => 'admin@example.com',
|
16
|
+
'avatarUrls' => {
|
17
|
+
'16x16' => 'http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122',
|
18
|
+
'48x48' => 'http://localhost:2990/jira/secure/useravatar?avatarId=10122'
|
19
|
+
},
|
20
|
+
'displayName' => 'admin',
|
21
|
+
'active' => true,
|
22
|
+
'timeZone' => 'Pacific/Auckland',
|
23
|
+
'groups' => {
|
24
|
+
'size' => 3,
|
25
|
+
'items' => []
|
26
|
+
},
|
27
|
+
'expand' => 'groups'
|
15
28
|
}
|
16
29
|
end
|
17
30
|
|
18
|
-
|
19
|
-
|
31
|
+
it_behaves_like 'a resource'
|
32
|
+
it_behaves_like 'a resource with a singular GET endpoint'
|
20
33
|
|
21
34
|
describe '#all' do
|
22
35
|
let(:client) do
|
23
36
|
client = double(options: { rest_base_path: '/jira/rest/api/2' })
|
24
|
-
allow(client).to receive(:get).with('/rest/api/2/users/search?username=_&maxResults=1000')
|
37
|
+
allow(client).to receive(:get).with('/rest/api/2/users/search?username=_&maxResults=1000')
|
38
|
+
.and_return(JIRA::Resource::UserFactory.new(client))
|
25
39
|
client
|
26
40
|
end
|
27
41
|
|
@@ -34,7 +48,7 @@ describe JIRA::Resource::User do
|
|
34
48
|
it 'gets users with maxResults of 1000' do
|
35
49
|
expect(client).to receive(:get).with('/rest/api/2/users/search?username=_&maxResults=1000')
|
36
50
|
expect(client).to receive_message_chain(:User, :build).with('User1')
|
37
|
-
|
51
|
+
described_class.all(client)
|
38
52
|
end
|
39
53
|
end
|
40
54
|
end
|
@@ -10,7 +10,7 @@ describe JIRA::Resource::Version do
|
|
10
10
|
let(:expected_attributes) do
|
11
11
|
{
|
12
12
|
'self' => 'http://localhost:2990/jira/rest/api/2/version/10000',
|
13
|
-
'id'
|
13
|
+
'id' => key,
|
14
14
|
'description' => 'Initial version'
|
15
15
|
}
|
16
16
|
end
|
@@ -29,11 +29,11 @@ describe JIRA::Resource::Version do
|
|
29
29
|
{ 'id' => '10000', 'name' => '2.0.0' }
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
it_behaves_like 'a resource'
|
33
|
+
it_behaves_like 'a resource with a singular GET endpoint'
|
34
|
+
it_behaves_like 'a resource with a DELETE endpoint'
|
35
|
+
it_behaves_like 'a resource with a POST endpoint'
|
36
|
+
it_behaves_like 'a resource with a PUT endpoint'
|
37
|
+
it_behaves_like 'a resource with a PUT endpoint that rejects invalid fields'
|
38
38
|
end
|
39
39
|
end
|