jira-ruby 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.travis.yml +9 -0
  4. data/Gemfile +14 -0
  5. data/Guardfile +14 -0
  6. data/LICENSE +19 -0
  7. data/README.md +427 -0
  8. data/Rakefile +31 -0
  9. data/example.rb +224 -0
  10. data/http-basic-example.rb +113 -0
  11. data/jira-ruby.gemspec +35 -0
  12. data/lib/jira-ruby.rb +49 -0
  13. data/lib/jira/base.rb +525 -0
  14. data/lib/jira/base_factory.rb +46 -0
  15. data/lib/jira/client.rb +308 -0
  16. data/lib/jira/has_many_proxy.rb +42 -0
  17. data/lib/jira/http_client.rb +112 -0
  18. data/lib/jira/http_error.rb +14 -0
  19. data/lib/jira/jwt_client.rb +67 -0
  20. data/lib/jira/oauth_client.rb +114 -0
  21. data/lib/jira/railtie.rb +10 -0
  22. data/lib/jira/request_client.rb +31 -0
  23. data/lib/jira/resource/agile.rb +79 -0
  24. data/lib/jira/resource/applinks.rb +39 -0
  25. data/lib/jira/resource/attachment.rb +50 -0
  26. data/lib/jira/resource/board.rb +91 -0
  27. data/lib/jira/resource/board_configuration.rb +9 -0
  28. data/lib/jira/resource/comment.rb +12 -0
  29. data/lib/jira/resource/component.rb +8 -0
  30. data/lib/jira/resource/createmeta.rb +44 -0
  31. data/lib/jira/resource/field.rb +83 -0
  32. data/lib/jira/resource/filter.rb +15 -0
  33. data/lib/jira/resource/issue.rb +141 -0
  34. data/lib/jira/resource/issuelink.rb +20 -0
  35. data/lib/jira/resource/issuelinktype.rb +14 -0
  36. data/lib/jira/resource/issuetype.rb +8 -0
  37. data/lib/jira/resource/priority.rb +8 -0
  38. data/lib/jira/resource/project.rb +41 -0
  39. data/lib/jira/resource/rapidview.rb +67 -0
  40. data/lib/jira/resource/remotelink.rb +26 -0
  41. data/lib/jira/resource/resolution.rb +8 -0
  42. data/lib/jira/resource/serverinfo.rb +18 -0
  43. data/lib/jira/resource/sprint.rb +105 -0
  44. data/lib/jira/resource/sprint_report.rb +8 -0
  45. data/lib/jira/resource/status.rb +8 -0
  46. data/lib/jira/resource/transition.rb +29 -0
  47. data/lib/jira/resource/user.rb +30 -0
  48. data/lib/jira/resource/version.rb +8 -0
  49. data/lib/jira/resource/watcher.rb +35 -0
  50. data/lib/jira/resource/webhook.rb +37 -0
  51. data/lib/jira/resource/worklog.rb +14 -0
  52. data/lib/jira/tasks.rb +0 -0
  53. data/lib/jira/version.rb +3 -0
  54. data/lib/tasks/generate.rake +18 -0
  55. data/spec/integration/attachment_spec.rb +32 -0
  56. data/spec/integration/comment_spec.rb +52 -0
  57. data/spec/integration/component_spec.rb +39 -0
  58. data/spec/integration/field_spec.rb +32 -0
  59. data/spec/integration/issue_spec.rb +93 -0
  60. data/spec/integration/issuelinktype_spec.rb +26 -0
  61. data/spec/integration/issuetype_spec.rb +24 -0
  62. data/spec/integration/priority_spec.rb +24 -0
  63. data/spec/integration/project_spec.rb +49 -0
  64. data/spec/integration/rapidview_spec.rb +74 -0
  65. data/spec/integration/resolution_spec.rb +26 -0
  66. data/spec/integration/status_spec.rb +24 -0
  67. data/spec/integration/transition_spec.rb +49 -0
  68. data/spec/integration/user_spec.rb +41 -0
  69. data/spec/integration/version_spec.rb +39 -0
  70. data/spec/integration/watcher_spec.rb +62 -0
  71. data/spec/integration/webhook.rb +25 -0
  72. data/spec/integration/worklog_spec.rb +51 -0
  73. data/spec/jira/base_factory_spec.rb +45 -0
  74. data/spec/jira/base_spec.rb +598 -0
  75. data/spec/jira/client_spec.rb +291 -0
  76. data/spec/jira/has_many_proxy_spec.rb +46 -0
  77. data/spec/jira/http_client_spec.rb +328 -0
  78. data/spec/jira/http_error_spec.rb +24 -0
  79. data/spec/jira/jwt_uri_builder_spec.rb +59 -0
  80. data/spec/jira/oauth_client_spec.rb +162 -0
  81. data/spec/jira/request_client_spec.rb +41 -0
  82. data/spec/jira/resource/agile_spec.rb +135 -0
  83. data/spec/jira/resource/attachment_spec.rb +138 -0
  84. data/spec/jira/resource/board_spec.rb +224 -0
  85. data/spec/jira/resource/createmeta_spec.rb +258 -0
  86. data/spec/jira/resource/field_spec.rb +85 -0
  87. data/spec/jira/resource/filter_spec.rb +97 -0
  88. data/spec/jira/resource/issue_spec.rb +227 -0
  89. data/spec/jira/resource/issuelink_spec.rb +14 -0
  90. data/spec/jira/resource/project_factory_spec.rb +11 -0
  91. data/spec/jira/resource/project_spec.rb +123 -0
  92. data/spec/jira/resource/sprint_spec.rb +90 -0
  93. data/spec/jira/resource/user_factory_spec.rb +31 -0
  94. data/spec/jira/resource/worklog_spec.rb +22 -0
  95. data/spec/mock_responses/board/1.json +33 -0
  96. data/spec/mock_responses/board/1_issues.json +62 -0
  97. data/spec/mock_responses/component.post.json +28 -0
  98. data/spec/mock_responses/component/10000.invalid.put.json +5 -0
  99. data/spec/mock_responses/component/10000.json +39 -0
  100. data/spec/mock_responses/component/10000.put.json +39 -0
  101. data/spec/mock_responses/empty_issues.json +8 -0
  102. data/spec/mock_responses/field.json +32 -0
  103. data/spec/mock_responses/field/1.json +15 -0
  104. data/spec/mock_responses/issue.json +1108 -0
  105. data/spec/mock_responses/issue.post.json +5 -0
  106. data/spec/mock_responses/issue/10002.invalid.put.json +6 -0
  107. data/spec/mock_responses/issue/10002.json +126 -0
  108. data/spec/mock_responses/issue/10002.put.missing_field_update.json +6 -0
  109. data/spec/mock_responses/issue/10002/attachments/10000.json +20 -0
  110. data/spec/mock_responses/issue/10002/comment.json +65 -0
  111. data/spec/mock_responses/issue/10002/comment.post.json +29 -0
  112. data/spec/mock_responses/issue/10002/comment/10000.json +29 -0
  113. data/spec/mock_responses/issue/10002/comment/10000.put.json +29 -0
  114. data/spec/mock_responses/issue/10002/transitions.json +49 -0
  115. data/spec/mock_responses/issue/10002/transitions.post.json +1 -0
  116. data/spec/mock_responses/issue/10002/watchers.json +13 -0
  117. data/spec/mock_responses/issue/10002/worklog.json +98 -0
  118. data/spec/mock_responses/issue/10002/worklog.post.json +30 -0
  119. data/spec/mock_responses/issue/10002/worklog/10000.json +31 -0
  120. data/spec/mock_responses/issue/10002/worklog/10000.put.json +30 -0
  121. data/spec/mock_responses/issueLinkType.json +25 -0
  122. data/spec/mock_responses/issueLinkType/10000.json +7 -0
  123. data/spec/mock_responses/issuetype.json +42 -0
  124. data/spec/mock_responses/issuetype/5.json +8 -0
  125. data/spec/mock_responses/jira/rest/webhooks/1.0/webhook.json +11 -0
  126. data/spec/mock_responses/jira/rest/webhooks/1.0/webhook/2.json +11 -0
  127. data/spec/mock_responses/priority.json +42 -0
  128. data/spec/mock_responses/priority/1.json +8 -0
  129. data/spec/mock_responses/project.json +12 -0
  130. data/spec/mock_responses/project/SAMPLEPROJECT.issues.json +1108 -0
  131. data/spec/mock_responses/project/SAMPLEPROJECT.json +84 -0
  132. data/spec/mock_responses/rapidview.json +10 -0
  133. data/spec/mock_responses/rapidview/SAMPLEPROJECT.issues.full.json +276 -0
  134. data/spec/mock_responses/rapidview/SAMPLEPROJECT.issues.json +111 -0
  135. data/spec/mock_responses/rapidview/SAMPLEPROJECT.json +6 -0
  136. data/spec/mock_responses/resolution.json +15 -0
  137. data/spec/mock_responses/resolution/1.json +7 -0
  138. data/spec/mock_responses/sprint/1_issues.json +125 -0
  139. data/spec/mock_responses/status.json +37 -0
  140. data/spec/mock_responses/status/1.json +7 -0
  141. data/spec/mock_responses/user_username=admin.json +17 -0
  142. data/spec/mock_responses/version.post.json +7 -0
  143. data/spec/mock_responses/version/10000.invalid.put.json +5 -0
  144. data/spec/mock_responses/version/10000.json +11 -0
  145. data/spec/mock_responses/version/10000.put.json +7 -0
  146. data/spec/mock_responses/webhook.json +11 -0
  147. data/spec/mock_responses/webhook/webhook.json +11 -0
  148. data/spec/spec_helper.rb +21 -0
  149. data/spec/support/clients_helper.rb +16 -0
  150. data/spec/support/matchers/have_attributes.rb +11 -0
  151. data/spec/support/matchers/have_many.rb +9 -0
  152. data/spec/support/matchers/have_one.rb +5 -0
  153. data/spec/support/shared_examples/integration.rb +177 -0
  154. metadata +491 -0
@@ -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
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe JIRA::Resource::Resolution 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://www.example.com/jira/rest/api/2/resolution/1',
13
+ 'id' => key,
14
+ 'name' => 'Fixed',
15
+ 'description' => 'A fix for this issue is checked into the tree and tested.',
16
+ 'iconUrl' => 'http://www.example.com/jira/images/icons/status_resolved.gif'
17
+ }
18
+ end
19
+
20
+ let(:expected_collection_length) { 2 }
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::Status 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/status/1',
13
+ 'id' => key,
14
+ 'name' => 'Open'
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::Transition 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::Transition.new(client, attrs: { 'id' => '99999' }, issue_id: '10014') }
11
+
12
+ let(:belongs_to) do
13
+ JIRA::Resource::Issue.new(client, attrs: {
14
+ 'id' => '10002',
15
+ 'self' => "#{site_url}/jira/rest/api/2/issue/10002",
16
+ 'fields' => {
17
+ 'comment' => { 'comments' => [] }
18
+ }
19
+ })
20
+ end
21
+
22
+ let(:expected_attributes) do
23
+ {
24
+ 'self' => "#{site_url}/jira/rest/api/2/issue/10002/transition/10000",
25
+ 'id' => key
26
+ }
27
+ end
28
+
29
+ let(:attributes_for_post) do
30
+ {
31
+ 'transition' => {
32
+ 'id' => '42'
33
+ }
34
+ }
35
+ end
36
+
37
+ it_should_behave_like 'a resource'
38
+
39
+ describe 'POST endpoint' do
40
+ it 'saves a new resource' do
41
+ stub_request(:post, /#{described_class.collection_path(client, prefix)}$/)
42
+ .with(body: attributes_for_post.to_json)
43
+ .to_return(status: 200, body: get_mock_from_path(:post))
44
+ subject = build_receiver.build
45
+ expect(subject.save(attributes_for_post)).to be_truthy
46
+ end
47
+ end
48
+ end
49
+ end