zk-jira-ruby 2.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.travis.yml +9 -0
- data/Gemfile +14 -0
- data/Guardfile +14 -0
- data/LICENSE +19 -0
- data/README.md +427 -0
- data/Rakefile +31 -0
- data/example.rb +232 -0
- data/http-basic-example.rb +113 -0
- data/jira-ruby.gemspec +35 -0
- data/lib/jira/base.rb +525 -0
- data/lib/jira/base_factory.rb +46 -0
- data/lib/jira/client.rb +315 -0
- data/lib/jira/has_many_proxy.rb +42 -0
- data/lib/jira/http_client.rb +112 -0
- data/lib/jira/http_error.rb +14 -0
- data/lib/jira/jwt_client.rb +67 -0
- data/lib/jira/oauth_client.rb +114 -0
- data/lib/jira/railtie.rb +10 -0
- data/lib/jira/request_client.rb +31 -0
- data/lib/jira/resource/agile.rb +79 -0
- data/lib/jira/resource/applinks.rb +39 -0
- data/lib/jira/resource/attachment.rb +50 -0
- data/lib/jira/resource/board.rb +91 -0
- data/lib/jira/resource/board_configuration.rb +9 -0
- data/lib/jira/resource/comment.rb +12 -0
- data/lib/jira/resource/component.rb +8 -0
- data/lib/jira/resource/createmeta.rb +44 -0
- data/lib/jira/resource/field.rb +83 -0
- data/lib/jira/resource/filter.rb +15 -0
- data/lib/jira/resource/issue.rb +141 -0
- data/lib/jira/resource/issuelink.rb +20 -0
- data/lib/jira/resource/issuelinktype.rb +14 -0
- data/lib/jira/resource/issuetype.rb +8 -0
- data/lib/jira/resource/priority.rb +8 -0
- data/lib/jira/resource/project.rb +41 -0
- data/lib/jira/resource/rapidview.rb +67 -0
- data/lib/jira/resource/remotelink.rb +26 -0
- data/lib/jira/resource/resolution.rb +8 -0
- data/lib/jira/resource/serverinfo.rb +18 -0
- data/lib/jira/resource/sprint.rb +105 -0
- data/lib/jira/resource/sprint_report.rb +8 -0
- data/lib/jira/resource/status.rb +8 -0
- data/lib/jira/resource/transition.rb +29 -0
- data/lib/jira/resource/user.rb +30 -0
- data/lib/jira/resource/version.rb +66 -0
- data/lib/jira/resource/watcher.rb +35 -0
- data/lib/jira/resource/webhook.rb +37 -0
- data/lib/jira/resource/worklog.rb +14 -0
- data/lib/jira/tasks.rb +0 -0
- data/lib/jira/version.rb +3 -0
- data/lib/jira-ruby.rb +49 -0
- data/lib/tasks/generate.rake +18 -0
- data/spec/integration/attachment_spec.rb +32 -0
- data/spec/integration/comment_spec.rb +52 -0
- data/spec/integration/component_spec.rb +39 -0
- data/spec/integration/field_spec.rb +32 -0
- data/spec/integration/issue_spec.rb +93 -0
- data/spec/integration/issuelinktype_spec.rb +26 -0
- data/spec/integration/issuetype_spec.rb +24 -0
- data/spec/integration/priority_spec.rb +24 -0
- data/spec/integration/project_spec.rb +49 -0
- data/spec/integration/rapidview_spec.rb +74 -0
- data/spec/integration/resolution_spec.rb +26 -0
- data/spec/integration/status_spec.rb +24 -0
- data/spec/integration/transition_spec.rb +49 -0
- data/spec/integration/user_spec.rb +41 -0
- data/spec/integration/version_spec.rb +39 -0
- data/spec/integration/watcher_spec.rb +62 -0
- data/spec/integration/webhook.rb +25 -0
- data/spec/integration/worklog_spec.rb +51 -0
- data/spec/jira/base_factory_spec.rb +45 -0
- data/spec/jira/base_spec.rb +598 -0
- data/spec/jira/client_spec.rb +291 -0
- data/spec/jira/has_many_proxy_spec.rb +46 -0
- data/spec/jira/http_client_spec.rb +328 -0
- data/spec/jira/http_error_spec.rb +24 -0
- data/spec/jira/jwt_uri_builder_spec.rb +59 -0
- data/spec/jira/oauth_client_spec.rb +162 -0
- data/spec/jira/request_client_spec.rb +41 -0
- data/spec/jira/resource/agile_spec.rb +135 -0
- data/spec/jira/resource/attachment_spec.rb +138 -0
- data/spec/jira/resource/board_spec.rb +224 -0
- data/spec/jira/resource/createmeta_spec.rb +258 -0
- data/spec/jira/resource/field_spec.rb +85 -0
- data/spec/jira/resource/filter_spec.rb +97 -0
- data/spec/jira/resource/issue_spec.rb +227 -0
- data/spec/jira/resource/issuelink_spec.rb +14 -0
- data/spec/jira/resource/project_factory_spec.rb +11 -0
- data/spec/jira/resource/project_spec.rb +123 -0
- data/spec/jira/resource/sprint_spec.rb +90 -0
- data/spec/jira/resource/user_factory_spec.rb +31 -0
- data/spec/jira/resource/worklog_spec.rb +22 -0
- data/spec/mock_responses/board/1.json +33 -0
- data/spec/mock_responses/board/1_issues.json +62 -0
- data/spec/mock_responses/component/10000.invalid.put.json +5 -0
- data/spec/mock_responses/component/10000.json +39 -0
- data/spec/mock_responses/component/10000.put.json +39 -0
- data/spec/mock_responses/component.post.json +28 -0
- data/spec/mock_responses/empty_issues.json +8 -0
- data/spec/mock_responses/field/1.json +15 -0
- data/spec/mock_responses/field.json +32 -0
- data/spec/mock_responses/issue/10002/attachments/10000.json +20 -0
- data/spec/mock_responses/issue/10002/comment/10000.json +29 -0
- data/spec/mock_responses/issue/10002/comment/10000.put.json +29 -0
- data/spec/mock_responses/issue/10002/comment.json +65 -0
- data/spec/mock_responses/issue/10002/comment.post.json +29 -0
- data/spec/mock_responses/issue/10002/transitions.json +49 -0
- data/spec/mock_responses/issue/10002/transitions.post.json +1 -0
- data/spec/mock_responses/issue/10002/watchers.json +13 -0
- data/spec/mock_responses/issue/10002/worklog/10000.json +31 -0
- data/spec/mock_responses/issue/10002/worklog/10000.put.json +30 -0
- data/spec/mock_responses/issue/10002/worklog.json +98 -0
- data/spec/mock_responses/issue/10002/worklog.post.json +30 -0
- data/spec/mock_responses/issue/10002.invalid.put.json +6 -0
- data/spec/mock_responses/issue/10002.json +126 -0
- data/spec/mock_responses/issue/10002.put.missing_field_update.json +6 -0
- data/spec/mock_responses/issue.json +1108 -0
- data/spec/mock_responses/issue.post.json +5 -0
- data/spec/mock_responses/issueLinkType/10000.json +7 -0
- data/spec/mock_responses/issueLinkType.json +25 -0
- data/spec/mock_responses/issuetype/5.json +8 -0
- data/spec/mock_responses/issuetype.json +42 -0
- data/spec/mock_responses/jira/rest/webhooks/1.0/webhook/2.json +11 -0
- data/spec/mock_responses/jira/rest/webhooks/1.0/webhook.json +11 -0
- data/spec/mock_responses/priority/1.json +8 -0
- data/spec/mock_responses/priority.json +42 -0
- data/spec/mock_responses/project/SAMPLEPROJECT.issues.json +1108 -0
- data/spec/mock_responses/project/SAMPLEPROJECT.json +84 -0
- data/spec/mock_responses/project.json +12 -0
- data/spec/mock_responses/rapidview/SAMPLEPROJECT.issues.full.json +276 -0
- data/spec/mock_responses/rapidview/SAMPLEPROJECT.issues.json +111 -0
- data/spec/mock_responses/rapidview/SAMPLEPROJECT.json +6 -0
- data/spec/mock_responses/rapidview.json +10 -0
- data/spec/mock_responses/resolution/1.json +7 -0
- data/spec/mock_responses/resolution.json +15 -0
- data/spec/mock_responses/sprint/1_issues.json +125 -0
- data/spec/mock_responses/status/1.json +7 -0
- data/spec/mock_responses/status.json +37 -0
- data/spec/mock_responses/user_username=admin.json +17 -0
- data/spec/mock_responses/version/10000.invalid.put.json +5 -0
- data/spec/mock_responses/version/10000.json +11 -0
- data/spec/mock_responses/version/10000.put.json +7 -0
- data/spec/mock_responses/version.post.json +7 -0
- data/spec/mock_responses/webhook/webhook.json +11 -0
- data/spec/mock_responses/webhook.json +11 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/support/clients_helper.rb +16 -0
- data/spec/support/matchers/have_attributes.rb +11 -0
- data/spec/support/matchers/have_many.rb +9 -0
- data/spec/support/matchers/have_one.rb +5 -0
- data/spec/support/shared_examples/integration.rb +177 -0
- metadata +491 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
3
|
+
namespace :jira do
|
4
|
+
desc 'Generate a consumer key for your application'
|
5
|
+
task :generate_consumer_key do
|
6
|
+
key = SecureRandom.hex(16)
|
7
|
+
puts "You can use this as your consumer key: #{key}"
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Run the system call to generate a RSA public certificate'
|
11
|
+
task :generate_public_cert do
|
12
|
+
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: \'rsakey.pem\'."
|
15
|
+
puts 'You will need to copy the following certificate into your application link configuration in Jira:'
|
16
|
+
system('cat rsacert.pem')
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Attachment do
|
4
|
+
with_each_client do |site_url, client|
|
5
|
+
let(:client) { client }
|
6
|
+
let(:site_url) { site_url }
|
7
|
+
|
8
|
+
let(:key) { '10000' }
|
9
|
+
|
10
|
+
let(:target) { JIRA::Resource::Attachment.new(client, attrs: { 'id' => '99999' }, issue_id: '10002') }
|
11
|
+
|
12
|
+
let(:expected_attributes) do
|
13
|
+
{
|
14
|
+
'self' => 'http://localhost:2990/jira/rest/api/2/attachment/10000',
|
15
|
+
'size' => 15_360,
|
16
|
+
'filename' => 'ballmer.png'
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:belongs_to) do
|
21
|
+
JIRA::Resource::Issue.new(client, attrs: {
|
22
|
+
'id' => '10002',
|
23
|
+
'fields' => {
|
24
|
+
'attachment' => { 'attachments' => [] }
|
25
|
+
}
|
26
|
+
})
|
27
|
+
end
|
28
|
+
|
29
|
+
it_should_behave_like 'a resource with a singular GET endpoint'
|
30
|
+
it_should_behave_like 'a resource with a DELETE endpoint'
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Comment do
|
4
|
+
with_each_client do |site_url, client|
|
5
|
+
let(:client) { client }
|
6
|
+
let(:site_url) { site_url }
|
7
|
+
|
8
|
+
let(:key) { '10000' }
|
9
|
+
|
10
|
+
let(:target) { JIRA::Resource::Comment.new(client, attrs: { 'id' => '99999' }, issue_id: '54321') }
|
11
|
+
|
12
|
+
let(:expected_collection_length) { 2 }
|
13
|
+
|
14
|
+
let(:belongs_to) do
|
15
|
+
JIRA::Resource::Issue.new(client, attrs: {
|
16
|
+
'id' => '10002',
|
17
|
+
'fields' => {
|
18
|
+
'comment' => { 'comments' => [] }
|
19
|
+
}
|
20
|
+
})
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:expected_attributes) do
|
24
|
+
{
|
25
|
+
'self' => 'http://localhost:2990/jira/rest/api/2/issue/10002/comment/10000',
|
26
|
+
'id' => key,
|
27
|
+
'body' => 'This is a comment. Creative.'
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
let(:attributes_for_post) do
|
32
|
+
{ 'body' => 'new comment' }
|
33
|
+
end
|
34
|
+
let(:expected_attributes_from_post) do
|
35
|
+
{ 'id' => '10001', 'body' => 'new comment' }
|
36
|
+
end
|
37
|
+
|
38
|
+
let(:attributes_for_put) do
|
39
|
+
{ 'body' => 'new body' }
|
40
|
+
end
|
41
|
+
let(:expected_attributes_from_put) do
|
42
|
+
{ 'id' => '10000', 'body' => 'new body' }
|
43
|
+
end
|
44
|
+
|
45
|
+
it_should_behave_like 'a resource'
|
46
|
+
it_should_behave_like 'a resource with a collection GET endpoint'
|
47
|
+
it_should_behave_like 'a resource with a singular GET endpoint'
|
48
|
+
it_should_behave_like 'a resource with a DELETE endpoint'
|
49
|
+
it_should_behave_like 'a resource with a POST endpoint'
|
50
|
+
it_should_behave_like 'a resource with a PUT endpoint'
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Component do
|
4
|
+
with_each_client do |site_url, client|
|
5
|
+
let(:client) { client }
|
6
|
+
let(:site_url) { site_url }
|
7
|
+
|
8
|
+
let(:key) { '10000' }
|
9
|
+
|
10
|
+
let(:expected_attributes) do
|
11
|
+
{
|
12
|
+
'self' => 'http://localhost:2990/jira/rest/api/2/component/10000',
|
13
|
+
'id' => key,
|
14
|
+
'name' => 'Cheesecake'
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:attributes_for_post) do
|
19
|
+
{ 'name' => 'Test component', 'project' => 'SAMPLEPROJECT' }
|
20
|
+
end
|
21
|
+
let(:expected_attributes_from_post) do
|
22
|
+
{ 'id' => '10001', 'name' => 'Test component' }
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:attributes_for_put) do
|
26
|
+
{ 'name' => 'Jammy', 'project' => 'SAMPLEPROJECT' }
|
27
|
+
end
|
28
|
+
let(:expected_attributes_from_put) do
|
29
|
+
{ 'id' => '10000', 'name' => 'Jammy' }
|
30
|
+
end
|
31
|
+
|
32
|
+
it_should_behave_like 'a resource'
|
33
|
+
it_should_behave_like 'a resource with a singular GET endpoint'
|
34
|
+
it_should_behave_like 'a resource with a DELETE endpoint'
|
35
|
+
it_should_behave_like 'a resource with a POST endpoint'
|
36
|
+
it_should_behave_like 'a resource with a PUT endpoint'
|
37
|
+
it_should_behave_like 'a resource with a PUT endpoint that rejects invalid fields'
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Field 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
|
+
{
|
12
|
+
'id' => key,
|
13
|
+
'name' => 'Description',
|
14
|
+
'custom' => false,
|
15
|
+
'orderable' => true,
|
16
|
+
'navigable' => true,
|
17
|
+
'searchable' => true,
|
18
|
+
'clauseNames' => ['description'],
|
19
|
+
'schema' => {
|
20
|
+
'type' => 'string',
|
21
|
+
'system' => 'description'
|
22
|
+
}
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
let(:expected_collection_length) { 2 }
|
27
|
+
|
28
|
+
it_should_behave_like 'a resource'
|
29
|
+
it_should_behave_like 'a resource with a collection GET endpoint'
|
30
|
+
it_should_behave_like 'a resource with a singular GET endpoint'
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Issue do
|
4
|
+
with_each_client do |site_url, client|
|
5
|
+
let(:client) { client }
|
6
|
+
let(:site_url) { site_url }
|
7
|
+
|
8
|
+
let(:key) { '10002' }
|
9
|
+
|
10
|
+
let(:expected_attributes) do
|
11
|
+
{
|
12
|
+
'self' => 'http://localhost:2990/jira/rest/api/2/issue/10002',
|
13
|
+
'key' => 'SAMPLEPROJECT-1',
|
14
|
+
'expand' => 'renderedFields,names,schema,transitions,editmeta,changelog'
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:attributes_for_post) do
|
19
|
+
{ 'foo' => 'bar' }
|
20
|
+
end
|
21
|
+
let(:expected_attributes_from_post) do
|
22
|
+
{ 'id' => '10005', 'key' => 'SAMPLEPROJECT-4' }
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:attributes_for_put) do
|
26
|
+
{ 'foo' => 'bar' }
|
27
|
+
end
|
28
|
+
let(:expected_attributes_from_put) do
|
29
|
+
{ 'foo' => 'bar' }
|
30
|
+
end
|
31
|
+
let(:expected_collection_length) { 11 }
|
32
|
+
|
33
|
+
it_should_behave_like 'a resource'
|
34
|
+
it_should_behave_like 'a resource with a singular GET endpoint'
|
35
|
+
describe 'GET all issues' do # JIRA::Resource::Issue.all uses the search endpoint
|
36
|
+
let(:client) { client }
|
37
|
+
let(:site_url) { site_url }
|
38
|
+
|
39
|
+
let(:expected_attributes) do
|
40
|
+
{
|
41
|
+
'id' => '10014',
|
42
|
+
'self' => 'http://localhost:2990/jira/rest/api/2/issue/10014',
|
43
|
+
'key' => 'SAMPLEPROJECT-13'
|
44
|
+
}
|
45
|
+
end
|
46
|
+
before(:each) do
|
47
|
+
stub_request(:get, site_url + '/jira/rest/api/2/search?expand=transitions.fields&maxResults=1000&startAt=0')
|
48
|
+
.to_return(status: 200, body: get_mock_response('issue.json'))
|
49
|
+
|
50
|
+
stub_request(:get, site_url + '/jira/rest/api/2/search?expand=transitions.fields&maxResults=1000&startAt=11')
|
51
|
+
.to_return(status: 200, body: get_mock_response('empty_issues.json'))
|
52
|
+
end
|
53
|
+
it_should_behave_like 'a resource with a collection GET endpoint'
|
54
|
+
end
|
55
|
+
it_should_behave_like 'a resource with a DELETE endpoint'
|
56
|
+
it_should_behave_like 'a resource with a POST endpoint'
|
57
|
+
it_should_behave_like 'a resource with a PUT endpoint'
|
58
|
+
it_should_behave_like 'a resource with a PUT endpoint that rejects invalid fields'
|
59
|
+
|
60
|
+
describe 'errors' do
|
61
|
+
before(:each) do
|
62
|
+
stub_request(:get,
|
63
|
+
site_url + '/jira/rest/api/2/issue/10002')
|
64
|
+
.to_return(status: 200, body: get_mock_response('issue/10002.json'))
|
65
|
+
stub_request(:put, site_url + '/jira/rest/api/2/issue/10002')
|
66
|
+
.with(body: '{"missing":"fields and update"}')
|
67
|
+
.to_return(status: 400, body: get_mock_response('issue/10002.put.missing_field_update.json'))
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'fails to save when fields and update are missing' do
|
71
|
+
subject = client.Issue.build('id' => '10002')
|
72
|
+
subject.fetch
|
73
|
+
expect(subject.save('missing' => 'fields and update')).to be_falsey
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe 'GET jql issues' do # JIRA::Resource::Issue.jql uses the search endpoint
|
78
|
+
jql_query_string = "PROJECT = 'SAMPLEPROJECT'"
|
79
|
+
let(:client) { client }
|
80
|
+
let(:site_url) { site_url }
|
81
|
+
let(:jql_query_string) { jql_query_string }
|
82
|
+
|
83
|
+
let(:expected_attributes) do
|
84
|
+
{
|
85
|
+
'id' => '10014',
|
86
|
+
'self' => 'http://localhost:2990/jira/rest/api/2/issue/10014',
|
87
|
+
'key' => 'SAMPLEPROJECT-13'
|
88
|
+
}
|
89
|
+
end
|
90
|
+
it_should_behave_like 'a resource with JQL inputs and a collection GET endpoint'
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Issuelinktype do
|
4
|
+
with_each_client do |site_url, client|
|
5
|
+
let(:client) { client }
|
6
|
+
let(:site_url) { site_url }
|
7
|
+
|
8
|
+
let(:key) { '10000' }
|
9
|
+
|
10
|
+
let(:expected_attributes) do
|
11
|
+
{
|
12
|
+
'id' => key,
|
13
|
+
'self' => 'http://localhost:2990/jira/rest/api/2/issueLinkType/10000',
|
14
|
+
'name' => 'Blocks',
|
15
|
+
'inward' => 'is blocked by',
|
16
|
+
'outward' => 'blocks'
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:expected_collection_length) { 3 }
|
21
|
+
|
22
|
+
it_should_behave_like 'a resource'
|
23
|
+
it_should_behave_like 'a resource with a collection GET endpoint'
|
24
|
+
it_should_behave_like 'a resource with a singular GET endpoint'
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Issuetype do
|
4
|
+
with_each_client do |site_url, client|
|
5
|
+
let(:client) { client }
|
6
|
+
let(:site_url) { site_url }
|
7
|
+
|
8
|
+
let(:key) { '5' }
|
9
|
+
|
10
|
+
let(:expected_attributes) do
|
11
|
+
{
|
12
|
+
'self' => 'http://localhost:2990/jira/rest/api/2/issuetype/5',
|
13
|
+
'id' => key,
|
14
|
+
'name' => 'Sub-task'
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:expected_collection_length) { 5 }
|
19
|
+
|
20
|
+
it_should_behave_like 'a resource'
|
21
|
+
it_should_behave_like 'a resource with a collection GET endpoint'
|
22
|
+
it_should_behave_like 'a resource with a singular GET endpoint'
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Priority 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
|
+
{
|
12
|
+
'self' => 'http://localhost:2990/jira/rest/api/2/priority/1',
|
13
|
+
'id' => key,
|
14
|
+
'name' => 'Blocker'
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:expected_collection_length) { 5 }
|
19
|
+
|
20
|
+
it_should_behave_like 'a resource'
|
21
|
+
it_should_behave_like 'a resource with a collection GET endpoint'
|
22
|
+
it_should_behave_like 'a resource with a singular GET endpoint'
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Project do
|
4
|
+
with_each_client do |site_url, client|
|
5
|
+
let(:client) { client }
|
6
|
+
let(:site_url) { site_url }
|
7
|
+
|
8
|
+
let(:key) { 'SAMPLEPROJECT' }
|
9
|
+
|
10
|
+
let(:expected_attributes) do
|
11
|
+
{
|
12
|
+
'self' => 'http://localhost:2990/jira/rest/api/2/project/SAMPLEPROJECT',
|
13
|
+
'key' => key,
|
14
|
+
'name' => 'Sample Project for Developing RoR RESTful API'
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:expected_collection_length) { 1 }
|
19
|
+
|
20
|
+
it_should_behave_like 'a resource'
|
21
|
+
it_should_behave_like 'a resource with a collection GET endpoint'
|
22
|
+
it_should_behave_like 'a resource with a singular GET endpoint'
|
23
|
+
|
24
|
+
describe 'issues' do
|
25
|
+
it 'returns all the issues' do
|
26
|
+
stub_request(:get, site_url + '/jira/rest/api/2/search?jql=project="SAMPLEPROJECT"')
|
27
|
+
.to_return(status: 200, body: get_mock_response('project/SAMPLEPROJECT.issues.json'))
|
28
|
+
subject = client.Project.build('key' => key)
|
29
|
+
issues = subject.issues
|
30
|
+
expect(issues.length).to eq(11)
|
31
|
+
issues.each do |issue|
|
32
|
+
expect(issue.class).to eq(JIRA::Resource::Issue)
|
33
|
+
expect(issue.expanded?).to be_falsey
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'returns a collection of components' do
|
39
|
+
stub_request(:get, site_url + described_class.singular_path(client, key))
|
40
|
+
.to_return(status: 200, body: get_mock_response('project/SAMPLEPROJECT.json'))
|
41
|
+
|
42
|
+
subject = client.Project.find(key)
|
43
|
+
expect(subject.components.length).to eq(2)
|
44
|
+
subject.components.each do |component|
|
45
|
+
expect(component.class).to eq(JIRA::Resource::Component)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::RapidView 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_collection_length) { 1 }
|
11
|
+
|
12
|
+
let(:expected_attributes) do
|
13
|
+
{
|
14
|
+
'id' => 1,
|
15
|
+
'name' => 'SAMPLEPROJECT',
|
16
|
+
'canEdit' => true,
|
17
|
+
'sprintSupportEnabled' => true
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
it_should_behave_like 'a resource'
|
22
|
+
# TODO@Anton: Add json file
|
23
|
+
# it_should_behave_like 'a resource with a singular GET endpoint'
|
24
|
+
|
25
|
+
describe 'GET all rapidviews' do
|
26
|
+
let(:client) { client }
|
27
|
+
let(:site_url) { site_url }
|
28
|
+
|
29
|
+
before(:each) do
|
30
|
+
stub_request(:get, site_url + '/jira/rest/greenhopper/1.0/rapidview')
|
31
|
+
.to_return(status: 200, body: get_mock_response('rapidview.json'))
|
32
|
+
end
|
33
|
+
it_should_behave_like 'a resource with a collection GET endpoint'
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'issues' do
|
37
|
+
it 'should return all the issues' do
|
38
|
+
stub_request(
|
39
|
+
:get,
|
40
|
+
site_url +
|
41
|
+
'/jira/rest/greenhopper/1.0/xboard/plan/backlog/data?rapidViewId=1'
|
42
|
+
).to_return(
|
43
|
+
status: 200,
|
44
|
+
body: get_mock_response('rapidview/SAMPLEPROJECT.issues.json')
|
45
|
+
)
|
46
|
+
|
47
|
+
stub_request(
|
48
|
+
:get,
|
49
|
+
site_url + '/jira/rest/api/2/search?jql=id IN(10001, 10000)'
|
50
|
+
).to_return(
|
51
|
+
status: 200,
|
52
|
+
body: get_mock_response('rapidview/SAMPLEPROJECT.issues.full.json')
|
53
|
+
)
|
54
|
+
|
55
|
+
stub_request(
|
56
|
+
:get,
|
57
|
+
site_url + '/jira/rest/api/2/search?jql=id IN(10000, 10001) AND sprint IS NOT EMPTY'
|
58
|
+
).to_return(
|
59
|
+
status: 200,
|
60
|
+
body: get_mock_response('rapidview/SAMPLEPROJECT.issues.full.json')
|
61
|
+
)
|
62
|
+
|
63
|
+
subject = client.RapidView.build('id' => 1)
|
64
|
+
issues = subject.issues
|
65
|
+
expect(issues.length).to eq(2)
|
66
|
+
|
67
|
+
issues.each do |issue|
|
68
|
+
expect(issue.class).to eq(JIRA::Resource::Issue)
|
69
|
+
expect(issue.expanded?).to be_falsey
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|