jira-ruby 2.3.0 → 3.0.0.beta2
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/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 +29 -0
- data/.github/workflows/codeql.yml +96 -0
- data/.github/workflows/rubocop.yml +18 -0
- data/.gitignore +3 -1
- data/.rubocop.yml +120 -0
- data/.yardopts +4 -0
- data/Gemfile +11 -3
- data/Guardfile +2 -0
- data/README.md +94 -18
- data/Rakefile +3 -4
- data/jira-ruby.gemspec +11 -17
- data/lib/jira/base.rb +37 -36
- data/lib/jira/base_factory.rb +4 -1
- data/lib/jira/client.rb +123 -50
- data/lib/jira/has_many_proxy.rb +32 -28
- data/lib/jira/http_client.rb +80 -13
- data/lib/jira/http_error.rb +4 -0
- data/lib/jira/jwt_client.rb +18 -42
- data/lib/jira/oauth_client.rb +68 -3
- data/lib/jira/railtie.rb +2 -0
- data/lib/jira/request_client.rb +31 -2
- data/lib/jira/resource/agile.rb +7 -9
- data/lib/jira/resource/applinks.rb +5 -3
- data/lib/jira/resource/attachment.rb +128 -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 +13 -12
- data/lib/jira/resource/filter.rb +2 -0
- data/lib/jira/resource/issue.rb +95 -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 +6 -3
- 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 +3 -2
- data/lib/jira/resource/webhook.rb +9 -3
- 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 +3 -1
- 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 +8 -8
- data/spec/integration/rapidview_spec.rb +10 -10
- 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 +34 -11
- data/spec/integration/version_spec.rb +7 -7
- data/spec/integration/watcher_spec.rb +21 -18
- data/spec/integration/webhook_spec.rb +33 -0
- data/spec/integration/worklog_spec.rb +8 -8
- data/spec/jira/base_factory_spec.rb +13 -3
- data/spec/jira/base_spec.rb +135 -98
- data/spec/jira/client_spec.rb +63 -47
- data/spec/jira/has_many_proxy_spec.rb +3 -3
- data/spec/jira/http_client_spec.rb +94 -27
- data/spec/jira/http_error_spec.rb +2 -2
- data/spec/jira/oauth_client_spec.rb +14 -8
- data/spec/jira/request_client_spec.rb +4 -4
- data/spec/jira/resource/agile_spec.rb +30 -30
- data/spec/jira/resource/attachment_spec.rb +170 -57
- data/spec/jira/resource/board_spec.rb +24 -23
- data/spec/jira/resource/createmeta_spec.rb +48 -48
- data/spec/jira/resource/field_spec.rb +44 -27
- data/spec/jira/resource/filter_spec.rb +4 -4
- data/spec/jira/resource/issue_picker_suggestions_spec.rb +17 -17
- data/spec/jira/resource/issue_spec.rb +49 -43
- 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 +14 -14
- data/spec/jira/resource/sprint_spec.rb +88 -9
- data/spec/jira/resource/status_spec.rb +21 -0
- data/spec/jira/resource/user_factory_spec.rb +5 -5
- data/spec/jira/resource/worklog_spec.rb +4 -4
- 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/mock_client.rb +9 -0
- data/spec/support/mock_response.rb +8 -0
- data/spec/support/shared_examples/integration.rb +25 -28
- metadata +27 -260
- 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/integration/webhook.rb +0 -25
- data/spec/jira/jwt_uri_builder_spec.rb +0 -59
@@ -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,36 +5,59 @@ 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
|
|
28
42
|
before do
|
43
|
+
user_factory = double('UserFactory')
|
44
|
+
|
29
45
|
allow(client).to receive(:get)
|
30
|
-
.with('/rest/api/2/users/search?username=_&maxResults=1000')
|
31
|
-
|
46
|
+
.with('/rest/api/2/users/search?username=_&maxResults=1000')
|
47
|
+
.and_return(double(body: '["User1"]'))
|
48
|
+
allow(client).to receive(:User).and_return(user_factory)
|
49
|
+
allow(user_factory).to receive(:build).with('users').and_return([])
|
32
50
|
end
|
33
51
|
|
34
52
|
it 'gets users with maxResults of 1000' do
|
53
|
+
user_factory = double('UserFactory')
|
54
|
+
|
35
55
|
expect(client).to receive(:get).with('/rest/api/2/users/search?username=_&maxResults=1000')
|
36
|
-
|
37
|
-
|
56
|
+
.and_return(double(body: '["User1"]'))
|
57
|
+
expect(client).to receive(:User).and_return(user_factory)
|
58
|
+
expect(user_factory).to receive(:build).with('User1')
|
59
|
+
|
60
|
+
described_class.all(client)
|
38
61
|
end
|
39
62
|
end
|
40
63
|
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
|
@@ -5,7 +5,7 @@ describe JIRA::Resource::Watcher do
|
|
5
5
|
let(:client) { client }
|
6
6
|
let(:site_url) { site_url }
|
7
7
|
|
8
|
-
let(:target) {
|
8
|
+
let(:target) { described_class.new(client, attrs: { 'id' => '99999' }, issue_id: '10002') }
|
9
9
|
|
10
10
|
let(:belongs_to) do
|
11
11
|
JIRA::Resource::Issue.new(client, attrs: {
|
@@ -19,44 +19,47 @@ describe JIRA::Resource::Watcher do
|
|
19
19
|
let(:expected_attributes) do
|
20
20
|
{
|
21
21
|
'self' => 'http://localhost:2990/jira/rest/api/2/issue/10002/watchers',
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
isWatching: false,
|
23
|
+
watchCount: 1,
|
24
|
+
watchers: [
|
25
25
|
{
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
self: 'http://www.example.com/jira/rest/api/2/user?username=admin',
|
27
|
+
name: 'admin',
|
28
|
+
displayName: 'admin',
|
29
|
+
active: false
|
30
30
|
}
|
31
31
|
]
|
32
32
|
}
|
33
33
|
end
|
34
34
|
|
35
35
|
describe 'watchers' do
|
36
|
-
before
|
37
|
-
stub_request(:get, site_url
|
36
|
+
before do
|
37
|
+
stub_request(:get, "#{site_url}/jira/rest/api/2/issue/10002")
|
38
38
|
.to_return(status: 200, body: get_mock_response('issue/10002.json'))
|
39
39
|
|
40
|
-
stub_request(:get, site_url
|
40
|
+
stub_request(:get, "#{site_url}/jira/rest/api/2/issue/10002/watchers")
|
41
41
|
.to_return(status: 200, body: get_mock_response('issue/10002/watchers.json'))
|
42
42
|
|
43
|
-
stub_request(:post, site_url
|
43
|
+
stub_request(:post, "#{site_url}/jira/rest/api/2/issue/10002/watchers")
|
44
44
|
.to_return(status: 204, body: nil)
|
45
45
|
end
|
46
46
|
|
47
|
-
it '
|
47
|
+
it 'returnses all the watchers' do
|
48
48
|
issue = client.Issue.find('10002')
|
49
|
-
watchers = client.Watcher.all(
|
49
|
+
watchers = client.Watcher.all({ issue: })
|
50
50
|
expect(watchers.length).to eq(1)
|
51
51
|
end
|
52
52
|
|
53
|
-
it '
|
53
|
+
it 'adds a watcher' do
|
54
54
|
issue = client.Issue.find('10002')
|
55
|
-
watcher =
|
56
|
-
user_id =
|
55
|
+
watcher = described_class.new(client, issue: issue)
|
56
|
+
user_id = 'tester'
|
57
|
+
|
57
58
|
watcher.save!(user_id)
|
59
|
+
|
60
|
+
expect(WebMock).to have_requested(:post, "#{site_url}/jira/rest/api/2/issue/10002/watchers")
|
61
|
+
.with(body: '"tester"')
|
58
62
|
end
|
59
63
|
end
|
60
|
-
|
61
64
|
end
|
62
65
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Webhook do
|
4
|
+
with_each_client do |site_url, client|
|
5
|
+
let(:client) { client }
|
6
|
+
let(:site_url) { site_url }
|
7
|
+
|
8
|
+
let(:key) { '2' }
|
9
|
+
|
10
|
+
let(:expected_attributes) do
|
11
|
+
{ 'name' => 'from API', 'url' => 'http://localhost:3000/webhooks/1', 'excludeBody' => false,
|
12
|
+
'filters' => { 'issue-related-events-section' => '' }, 'events' => [], 'enabled' => true, 'self' => 'http://localhost:2990/jira/rest/webhooks/1.0/webhook/2', 'lastUpdatedUser' => 'admin', 'lastUpdatedDisplayName' => 'admin', 'lastUpdated' => 1_453_306_520_188 }
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:expected_collection_length) { 1 }
|
16
|
+
|
17
|
+
it_behaves_like 'a resource'
|
18
|
+
it_behaves_like 'a resource with a collection GET endpoint'
|
19
|
+
it_behaves_like 'a resource with a singular GET endpoint'
|
20
|
+
|
21
|
+
it 'returns a collection of components' do
|
22
|
+
stub_request(:get, site_url + described_class.singular_path(client, key))
|
23
|
+
.to_return(status: 200, body: get_mock_response('webhook/webhook.json'))
|
24
|
+
|
25
|
+
webhook = client.Webhook.find(key)
|
26
|
+
|
27
|
+
expect(webhook).to be_a described_class
|
28
|
+
expect(webhook.name).to eq 'from API'
|
29
|
+
expect(webhook.url).to eq '/jira/rest/webhooks/1.0/webhook/2'
|
30
|
+
expect(webhook.enabled).to be true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -7,7 +7,7 @@ describe JIRA::Resource::Worklog 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) { 3 }
|
13
13
|
|
@@ -22,7 +22,7 @@ describe JIRA::Resource::Worklog do
|
|
22
22
|
let(:expected_attributes) do
|
23
23
|
{
|
24
24
|
'self' => 'http://localhost:2990/jira/rest/api/2/issue/10002/worklog/10000',
|
25
|
-
'id'
|
25
|
+
'id' => key,
|
26
26
|
'comment' => 'Some epic work.'
|
27
27
|
}
|
28
28
|
end
|
@@ -41,11 +41,11 @@ describe JIRA::Resource::Worklog do
|
|
41
41
|
{ 'id' => '10001', 'timeSpent' => '4d' }
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
it_behaves_like 'a resource'
|
45
|
+
it_behaves_like 'a resource with a collection GET endpoint'
|
46
|
+
it_behaves_like 'a resource with a singular GET endpoint'
|
47
|
+
it_behaves_like 'a resource with a DELETE endpoint'
|
48
|
+
it_behaves_like 'a resource with a POST endpoint'
|
49
|
+
it_behaves_like 'a resource with a PUT endpoint'
|
50
50
|
end
|
51
51
|
end
|
@@ -1,12 +1,22 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe JIRA::BaseFactory do
|
4
|
-
|
5
|
-
|
4
|
+
module JIRA
|
5
|
+
module Resource
|
6
|
+
class FooFactory < JIRA::BaseFactory; end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module JIRA
|
11
|
+
module Resource
|
12
|
+
class Foo; end
|
13
|
+
end
|
14
|
+
end
|
6
15
|
|
7
|
-
let(:client) { double }
|
8
16
|
subject { JIRA::Resource::FooFactory.new(client) }
|
9
17
|
|
18
|
+
let(:client) { double }
|
19
|
+
|
10
20
|
it 'initializes correctly' do
|
11
21
|
expect(subject.class).to eq(JIRA::Resource::FooFactory)
|
12
22
|
expect(subject.client).to eq(client)
|