jira-ruby 1.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +3 -0
  3. data/.travis.yml +5 -3
  4. data/Gemfile +7 -1
  5. data/Guardfile +1 -1
  6. data/README.md +452 -0
  7. data/Rakefile +6 -7
  8. data/example.rb +23 -1
  9. data/http-basic-example.rb +13 -12
  10. data/jira-ruby.gemspec +13 -13
  11. data/lib/jira/base.rb +53 -52
  12. data/lib/jira/base_factory.rb +3 -6
  13. data/lib/jira/client.rb +127 -30
  14. data/lib/jira/has_many_proxy.rb +0 -1
  15. data/lib/jira/http_client.rb +54 -16
  16. data/lib/jira/http_error.rb +3 -5
  17. data/lib/jira/jwt_client.rb +67 -0
  18. data/lib/jira/oauth_client.rb +47 -17
  19. data/lib/jira/request_client.rb +16 -5
  20. data/lib/jira/resource/agile.rb +34 -9
  21. data/lib/jira/resource/applinks.rb +5 -8
  22. data/lib/jira/resource/attachment.rb +41 -3
  23. data/lib/jira/resource/board.rb +91 -0
  24. data/lib/jira/resource/board_configuration.rb +9 -0
  25. data/lib/jira/resource/comment.rb +0 -2
  26. data/lib/jira/resource/component.rb +1 -3
  27. data/lib/jira/resource/createmeta.rb +12 -14
  28. data/lib/jira/resource/field.rb +22 -22
  29. data/lib/jira/resource/filter.rb +2 -2
  30. data/lib/jira/resource/issue.rb +69 -38
  31. data/lib/jira/resource/issue_picker_suggestions.rb +24 -0
  32. data/lib/jira/resource/issue_picker_suggestions_issue.rb +10 -0
  33. data/lib/jira/resource/issuelink.rb +3 -5
  34. data/lib/jira/resource/issuelinktype.rb +0 -1
  35. data/lib/jira/resource/issuetype.rb +1 -3
  36. data/lib/jira/resource/priority.rb +1 -3
  37. data/lib/jira/resource/project.rb +5 -7
  38. data/lib/jira/resource/rapidview.rb +28 -7
  39. data/lib/jira/resource/remotelink.rb +1 -4
  40. data/lib/jira/resource/resolution.rb +2 -4
  41. data/lib/jira/resource/serverinfo.rb +1 -2
  42. data/lib/jira/resource/sprint.rb +86 -17
  43. data/lib/jira/resource/sprint_report.rb +8 -0
  44. data/lib/jira/resource/status.rb +1 -3
  45. data/lib/jira/resource/suggested_issue.rb +9 -0
  46. data/lib/jira/resource/transition.rb +2 -6
  47. data/lib/jira/resource/user.rb +12 -2
  48. data/lib/jira/resource/version.rb +1 -3
  49. data/lib/jira/resource/watcher.rb +35 -0
  50. data/lib/jira/resource/webhook.rb +3 -6
  51. data/lib/jira/resource/worklog.rb +3 -5
  52. data/lib/jira/version.rb +1 -1
  53. data/lib/jira-ruby.rb +12 -2
  54. data/lib/tasks/generate.rake +4 -4
  55. data/spec/integration/attachment_spec.rb +17 -8
  56. data/spec/integration/comment_spec.rb +31 -34
  57. data/spec/integration/component_spec.rb +21 -24
  58. data/spec/integration/field_spec.rb +15 -18
  59. data/spec/integration/issue_spec.rb +45 -46
  60. data/spec/integration/issuelinktype_spec.rb +8 -11
  61. data/spec/integration/issuetype_spec.rb +5 -7
  62. data/spec/integration/priority_spec.rb +5 -8
  63. data/spec/integration/project_spec.rb +13 -20
  64. data/spec/integration/rapidview_spec.rb +17 -10
  65. data/spec/integration/resolution_spec.rb +7 -10
  66. data/spec/integration/status_spec.rb +5 -8
  67. data/spec/integration/transition_spec.rb +17 -20
  68. data/spec/integration/user_spec.rb +24 -8
  69. data/spec/integration/version_spec.rb +21 -25
  70. data/spec/integration/watcher_spec.rb +62 -0
  71. data/spec/integration/webhook.rb +8 -17
  72. data/spec/integration/worklog_spec.rb +30 -34
  73. data/spec/jira/base_factory_spec.rb +11 -12
  74. data/spec/jira/base_spec.rb +216 -229
  75. data/spec/jira/client_spec.rb +227 -159
  76. data/spec/jira/has_many_proxy_spec.rb +11 -12
  77. data/spec/jira/http_client_spec.rb +254 -31
  78. data/spec/jira/http_error_spec.rb +7 -9
  79. data/spec/jira/jwt_uri_builder_spec.rb +59 -0
  80. data/spec/jira/oauth_client_spec.rb +110 -39
  81. data/spec/jira/request_client_spec.rb +36 -9
  82. data/spec/jira/resource/agile_spec.rb +135 -0
  83. data/spec/jira/resource/attachment_spec.rb +127 -9
  84. data/spec/jira/resource/board_spec.rb +224 -0
  85. data/spec/jira/resource/createmeta_spec.rb +29 -32
  86. data/spec/jira/resource/field_spec.rb +42 -48
  87. data/spec/jira/resource/filter_spec.rb +40 -40
  88. data/spec/jira/resource/issue_picker_suggestions_spec.rb +79 -0
  89. data/spec/jira/resource/issue_spec.rb +88 -85
  90. data/spec/jira/resource/issuelink_spec.rb +1 -1
  91. data/spec/jira/resource/jira_picker_suggestions_issue_spec.rb +18 -0
  92. data/spec/jira/resource/project_factory_spec.rb +2 -4
  93. data/spec/jira/resource/project_spec.rb +33 -33
  94. data/spec/jira/resource/sprint_spec.rb +90 -0
  95. data/spec/jira/resource/user_factory_spec.rb +6 -8
  96. data/spec/jira/resource/worklog_spec.rb +9 -11
  97. data/spec/mock_responses/board/1.json +33 -0
  98. data/spec/mock_responses/board/1_issues.json +62 -0
  99. data/spec/mock_responses/empty_issues.json +8 -0
  100. data/spec/mock_responses/issue/10002/watchers.json +13 -0
  101. data/spec/mock_responses/issue.json +1 -1
  102. data/spec/mock_responses/sprint/1_issues.json +125 -0
  103. data/spec/spec_helper.rb +8 -9
  104. data/spec/support/clients_helper.rb +4 -4
  105. data/spec/support/shared_examples/integration.rb +60 -77
  106. metadata +115 -55
  107. data/.ruby-version +0 -1
  108. data/README.rdoc +0 -333
  109. /data/spec/mock_responses/{attachment → issue/10002/attachments}/10000.json +0 -0
@@ -1,14 +1,41 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::RequestClient do
4
+ let(:request_client) { JIRA::RequestClient.new }
4
5
 
5
- it "raises an exception for non success responses" do
6
- response = double()
7
- allow(response).to receive(:kind_of?).with(Net::HTTPSuccess).and_return(false)
8
- rc = JIRA::RequestClient.new
9
- expect(rc).to receive(:make_request).with(:get, '/foo', '', {}).and_return(response)
10
- expect {
11
- rc.request(:get, '/foo', '', {})
12
- }.to raise_exception(JIRA::HTTPError)
6
+ describe '#request' do
7
+ subject(:request) { request_client.request(:get, '/foo', '', {}) }
8
+
9
+ context 'when doing a request fails' do
10
+ let(:response) { double }
11
+
12
+ before do
13
+ allow(response).to receive(:kind_of?).with(Net::HTTPSuccess).and_return(false)
14
+ allow(request_client).to receive(:make_request).with(:get, '/foo', '', {}).and_return(response)
15
+ end
16
+
17
+ it 'raises an exception' do
18
+ expect{ subject }.to raise_exception(JIRA::HTTPError)
19
+ end
20
+ end
21
+ end
22
+
23
+ describe '#request_multipart' do
24
+ subject(:request) { request_client.request_multipart('/foo', data, {}) }
25
+
26
+ let(:data) { double }
27
+
28
+ context 'when doing a request fails' do
29
+ let(:response) { double }
30
+
31
+ before do
32
+ allow(response).to receive(:kind_of?).with(Net::HTTPSuccess).and_return(false)
33
+ allow(request_client).to receive(:make_multipart_request).with('/foo', data, {}).and_return(response)
34
+ end
35
+
36
+ it 'raises an exception' do
37
+ expect{ subject }.to raise_exception(JIRA::HTTPError)
38
+ end
39
+ end
13
40
  end
14
- end
41
+ end
@@ -0,0 +1,135 @@
1
+ require 'spec_helper'
2
+
3
+ describe JIRA::Resource::Agile do
4
+ let(:client) do
5
+ client = double(options: { rest_base_path: '/jira/rest/api/2', context_path: '/jira' })
6
+ allow(client).to receive(:Issue).and_return(JIRA::Resource::IssueFactory.new(client))
7
+ client
8
+ end
9
+ let(:response) { double }
10
+
11
+ describe '#all' do
12
+ it 'should query url without parameters' do
13
+ expect(client).to receive(:get).with('/jira/rest/agile/1.0/board').and_return(response)
14
+ expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
15
+
16
+ JIRA::Resource::Agile.all(client)
17
+ end
18
+ end
19
+
20
+ describe '#get_backlog_issues' do
21
+ it 'should query the url without parameters' do
22
+ expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/backlog?maxResults=100').and_return(response)
23
+ expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
24
+
25
+ JIRA::Resource::Agile.get_backlog_issues(client, 1)
26
+ end
27
+ end
28
+
29
+ describe '#get_board_issues' do
30
+ it 'should query correct url without parameters' do
31
+ expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/issue?').and_return(response)
32
+ expect(response).to receive(:body).and_return(get_mock_response('board/1_issues.json'))
33
+
34
+ expect(client).to receive(:get).with('/jira/rest/api/2/search?jql=id+IN%2810546%2C+10547%2C+10556%2C+10557%2C+10558%2C+10559%2C+10600%2C+10601%2C+10604%29').and_return(response)
35
+ expect(response).to receive(:body).and_return(get_mock_response('board/1_issues.json'))
36
+
37
+ issues = JIRA::Resource::Agile.get_board_issues(client, 1)
38
+ expect(issues).to be_an(Array)
39
+ expect(issues.size).to eql(9)
40
+
41
+ issues.each do |issue|
42
+ expect(issue.class).to eq(JIRA::Resource::Issue)
43
+ expect(issue.expanded?).to be_falsey
44
+ end
45
+ end
46
+
47
+ it 'should query correct url with parameters' do
48
+ expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/issue?startAt=50').and_return(response)
49
+ expect(response).to receive(:body).and_return(get_mock_response('board/1_issues.json'))
50
+
51
+ expect(client).to receive(:get).with('/jira/rest/api/2/search?jql=id+IN%2810546%2C+10547%2C+10556%2C+10557%2C+10558%2C+10559%2C+10600%2C+10601%2C+10604%29').and_return(response)
52
+ expect(response).to receive(:body).and_return(get_mock_response('board/1_issues.json'))
53
+
54
+ issues = JIRA::Resource::Agile.get_board_issues(client, 1, startAt: 50)
55
+ expect(issues).to be_an(Array)
56
+ expect(issues.size).to eql(9)
57
+
58
+ issues.each do |issue|
59
+ expect(issue.class).to eq(JIRA::Resource::Issue)
60
+ expect(issue.expanded?).to be_falsey
61
+ end
62
+ end
63
+ end
64
+
65
+ describe '#get_sprints' do
66
+ it 'should query correct url without parameters' do
67
+ expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/sprint?maxResults=100').and_return(response)
68
+ expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
69
+
70
+ JIRA::Resource::Agile.get_sprints(client, 1)
71
+ end
72
+
73
+ it 'should query correct url with parameters' do
74
+ expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/sprint?startAt=50&maxResults=100').and_return(response)
75
+ expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
76
+
77
+ JIRA::Resource::Agile.get_sprints(client, 1, startAt: 50)
78
+ end
79
+
80
+ it 'should work with pagination starting at 0' do
81
+ expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/sprint?maxResults=1&startAt=0').and_return(response)
82
+ expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
83
+
84
+ JIRA::Resource::Agile.get_sprints(client, 1, maxResults: 1, startAt: 0)
85
+ end
86
+
87
+ it 'should work with pagination not starting at 0' do
88
+ expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/sprint?maxResults=1&startAt=1').and_return(response)
89
+ expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
90
+
91
+ JIRA::Resource::Agile.get_sprints(client, 1, maxResults: 1, startAt: 1)
92
+ end
93
+ end
94
+
95
+ describe '#get_sprint_issues' do
96
+ it 'should query correct url without parameters' do
97
+ expect(client).to receive(:get).with('/jira/rest/agile/1.0/sprint/1/issue?maxResults=100').and_return(response)
98
+ expect(response).to receive(:body).and_return(get_mock_response('sprint/1_issues.json'))
99
+
100
+ JIRA::Resource::Agile.get_sprint_issues(client, 1)
101
+ end
102
+
103
+ it 'should query correct url with parameters' do
104
+ expect(client).to receive(:get).with('/jira/rest/agile/1.0/sprint/1/issue?startAt=50&maxResults=100').and_return(response)
105
+ expect(response).to receive(:body).and_return(get_mock_response('sprint/1_issues.json'))
106
+
107
+ JIRA::Resource::Agile.get_sprint_issues(client, 1, startAt: 50)
108
+ end
109
+ end
110
+
111
+ describe '#get_projects_full' do
112
+ it 'should query correct url without parameters' do
113
+ expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/project/full').and_return(response)
114
+ expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
115
+
116
+ JIRA::Resource::Agile.get_projects_full(client, 1)
117
+ end
118
+ end
119
+
120
+ describe '#get_projects' do
121
+ it 'should query correct url without parameters' do
122
+ expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/project?maxResults=100').and_return(response)
123
+ expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
124
+
125
+ JIRA::Resource::Agile.get_projects(client, 1)
126
+ end
127
+
128
+ it 'should query correct url with parameters' do
129
+ expect(client).to receive(:get).with('/jira/rest/agile/1.0/board/1/project?startAt=50&maxResults=100').and_return(response)
130
+ expect(response).to receive(:body).and_return(get_mock_response('board/1.json'))
131
+
132
+ JIRA::Resource::Agile.get_projects(client, 1, startAt: 50)
133
+ end
134
+ end
135
+ end
@@ -1,20 +1,138 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::Resource::Attachment do
4
+ subject(:attachment) do
5
+ JIRA::Resource::Attachment.new(
6
+ client,
7
+ issue: JIRA::Resource::Issue.new(client),
8
+ attrs: { 'author' => { 'foo' => 'bar' } }
9
+ )
10
+ end
4
11
 
5
- let(:client) { double() }
6
-
7
- describe "relationships" do
8
- subject {
9
- JIRA::Resource::Attachment.new(client, :attrs => {
10
- 'author' => {'foo' => 'bar'}
11
- })
12
- }
12
+ let(:client) do
13
+ double(
14
+ 'client',
15
+ options: {
16
+ rest_base_path: '/jira/rest/api/2'
17
+ },
18
+ request_client: double(
19
+ options: {
20
+ username: 'username',
21
+ password: 'password'
22
+ }
23
+ )
24
+ )
25
+ end
13
26
 
14
- it "has the correct relationships" do
27
+ describe 'relationships' do
28
+ it 'has an author' do
15
29
  expect(subject).to have_one(:author, JIRA::Resource::User)
30
+ end
31
+
32
+ it 'has the correct author name' do
16
33
  expect(subject.author.foo).to eq('bar')
17
34
  end
18
35
  end
19
36
 
37
+ describe '.meta' do
38
+ subject { JIRA::Resource::Attachment.meta(client) }
39
+
40
+ let(:response) do
41
+ double(
42
+ 'response',
43
+ body: '{"enabled":true,"uploadLimit":10485760}'
44
+ )
45
+ end
46
+
47
+ it 'returns meta information about attachment upload' do
48
+ expect(client).to receive(:get).with('/jira/rest/api/2/attachment/meta').and_return(response)
49
+
50
+ subject
51
+ end
52
+
53
+ context 'the factory delegates correctly' do
54
+ subject { JIRA::Resource::AttachmentFactory.new(client) }
55
+
56
+ it 'delegates #meta to to target class' do
57
+ expect(subject).to respond_to(:meta)
58
+ end
59
+ end
60
+ end
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
77
+ )
78
+ end
79
+ let(:issue) { JIRA::Resource::Issue.new(client) }
80
+
81
+ before do
82
+ allow(client).to receive(:post_multipart).and_return(response)
83
+ end
84
+
85
+ it 'successfully update the attachment' do
86
+ subject
87
+
88
+ expect(attachment.filename).to eq 'picture.jpg'
89
+ expect(attachment.mimeType).to eq 'image/jpeg'
90
+ expect(attachment.size).to eq 23_123
91
+ end
92
+ end
93
+
94
+ describe '#save!' do
95
+ subject { attachment.save!('file' => path_to_file) }
96
+
97
+ let(:path_to_file) { './spec/mock_responses/issue.json' }
98
+ let(:response) do
99
+ double(
100
+ body: [
101
+ {
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
+ }
109
+ ].to_json
110
+ )
111
+ end
112
+ let(:issue) { JIRA::Resource::Issue.new(client) }
113
+
114
+ before do
115
+ allow(client).to receive(:post_multipart).and_return(response)
116
+ end
117
+
118
+ it 'successfully update the attachment' do
119
+ subject
120
+
121
+ expect(attachment.filename).to eq 'picture.jpg'
122
+ expect(attachment.mimeType).to eq 'image/jpeg'
123
+ expect(attachment.size).to eq 23_123
124
+ end
125
+
126
+ context 'when passing in a symbol as file key' do
127
+ subject { attachment.save!(file: path_to_file) }
128
+
129
+ it 'successfully update the attachment' do
130
+ subject
131
+
132
+ expect(attachment.filename).to eq 'picture.jpg'
133
+ expect(attachment.mimeType).to eq 'image/jpeg'
134
+ expect(attachment.size).to eq 23_123
135
+ end
136
+ end
137
+ end
20
138
  end
@@ -0,0 +1,224 @@
1
+ require 'spec_helper'
2
+ require 'active_support/core_ext/hash'
3
+
4
+ describe JIRA::Resource::Board do
5
+ class JIRAResourceDelegation < SimpleDelegator # :nodoc:
6
+ end
7
+
8
+ let(:client) do
9
+ double(options: {
10
+ rest_base_path: '/jira/rest/api/2',
11
+ context_path: ''
12
+ })
13
+ end
14
+
15
+ let(:board) do
16
+ response = double
17
+ api_json_board = "{
18
+ \"id\": 84,
19
+ \"self\": \"http://www.example.com/jira/rest/agile/1.0/board/84\",
20
+ \"name\": \"scrum board\",
21
+ \"type\": \"scrum\"
22
+ }"
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)
26
+
27
+ expect(client).to receive(:Board).and_return(JIRA::Resource::BoardFactory.new(client))
28
+ JIRA::Resource::Board.find(client, '84')
29
+ end
30
+
31
+ it 'should find all boards' do
32
+ response = double
33
+ api_json = <<eos
34
+ {
35
+ "maxResults": 50,
36
+ "startAt": 0,
37
+ "isLast": true,
38
+ "values": [
39
+ {
40
+ "id": 84,
41
+ "name": "scrum board",
42
+ "type": "scrum"
43
+ },
44
+ {
45
+ "id": 92,
46
+ "name": "kanban board",
47
+ "type": "kanban"
48
+ }
49
+ ]
50
+ }
51
+ eos
52
+ allow(response).to receive(:body).and_return(api_json)
53
+ expect(client).to receive(:get).with('/rest/agile/1.0/board')
54
+ .and_return(response)
55
+ expect(client).to receive(:Board).twice.and_return(JIRA::Resource::BoardFactory.new(client))
56
+ boards = JIRA::Resource::Board.all(client)
57
+ expect(boards.count).to eq(2)
58
+ end
59
+
60
+ it 'should find one board by id' do
61
+ expect(board).to be_a(JIRA::Resource::Board)
62
+ end
63
+
64
+ describe '#issues' do
65
+ it 'should find all issues' do
66
+ issues_response = double
67
+
68
+ api_json_issues = <<eos
69
+ {
70
+ "expand": "names,schema",
71
+ "startAt": 0,
72
+ "maxResults": 50,
73
+ "total": 1,
74
+ "issues": [
75
+ {
76
+ "id": "10001",
77
+ "fields": {
78
+ "sprint": {
79
+ "id": 37,
80
+ "state": "future",
81
+ "name": "sprint 2"
82
+ },
83
+ "description": "example bug report"
84
+ }
85
+ }
86
+ ]
87
+ }
88
+ eos
89
+
90
+ allow(issues_response).to receive(:body).and_return(api_json_issues)
91
+ allow(board).to receive(:id).and_return(84)
92
+ expect(client).to receive(:get).with('/rest/agile/1.0/board/84/issue')
93
+ .and_return(issues_response)
94
+ expect(client).to receive(:Issue).and_return(JIRA::Resource::IssueFactory.new(client))
95
+
96
+ expect(board.issues.size).to be(1)
97
+ end
98
+
99
+ describe 'pagination' do
100
+ subject { described_class.new(client) }
101
+ let(:client) { JIRA::Client.new }
102
+
103
+ before do
104
+ allow(subject).to receive(:id).and_return('123')
105
+ end
106
+
107
+ context 'when there are multiple pages of results' do
108
+ let(:result_1) do
109
+ OpenStruct.new(body: {
110
+ 'startAt' => 0,
111
+ 'maxResults' => 1,
112
+ 'total' => 2,
113
+ 'issues' => []
114
+ }.to_json)
115
+ end
116
+ let(:result_2) do
117
+ OpenStruct.new(body: {
118
+ 'startAt' => 1,
119
+ 'maxResults' => 1,
120
+ 'total' => 2,
121
+ 'issues' => []
122
+ }.to_json)
123
+ end
124
+
125
+ it 'makes multiple requests and increments the startAt param' do
126
+ expect(client).to receive(:get).and_return(result_1)
127
+ expect(client).to receive(:get).and_return(result_2)
128
+ subject.issues
129
+ end
130
+ end
131
+
132
+ context 'when there is only one page of results' do
133
+ let(:result_1) do
134
+ OpenStruct.new(body: {
135
+ 'startAt' => 0,
136
+ 'maxResults' => 2,
137
+ 'total' => 2,
138
+ 'issues' => []
139
+ }.to_json)
140
+ end
141
+
142
+ it 'only requires one request' do
143
+ expect(client).to receive(:get).once.and_return(result_1)
144
+ subject.issues
145
+ end
146
+ end
147
+ end
148
+ end
149
+
150
+ it 'should get all sprints for a board' do
151
+ response = double
152
+
153
+ api_json = <<-eos
154
+ {
155
+ "values": [
156
+ {
157
+ "id": 37,
158
+ "state": "closed",
159
+ "name": "sprint 1"
160
+ },
161
+ {
162
+ "id": 72,
163
+ "state": "future",
164
+ "name": "sprint 2"
165
+ }
166
+ ]
167
+ }
168
+ eos
169
+ allow(response).to receive(:body).and_return(api_json)
170
+ allow(board).to receive(:id).and_return(84)
171
+ expect(client).to receive(:get).with('/rest/agile/1.0/board/84/sprint?').and_return(response)
172
+ expect(client).to receive(:Sprint).twice.and_return(JIRA::Resource::SprintFactory.new(client))
173
+ expect(board.sprints.size).to be(2)
174
+ end
175
+
176
+ it 'should get board configuration for a board' do
177
+ response = double
178
+
179
+ api_json = <<-eos
180
+ {
181
+ "id":1,
182
+ "name":"My Board",
183
+ "type":"kanban",
184
+ "self":"https://mycompany.atlassian.net/rest/agile/1.0/board/1/configuration",
185
+ "location":{
186
+ "type":"project",
187
+ "key":"MYPROJ",
188
+ "id":"10000",
189
+ "self":"https://mycompany.atlassian.net/rest/api/2/project/10000",
190
+ "name":"My Project"
191
+ },
192
+ "filter":{
193
+ "id":"10000",
194
+ "self":"https://mycompany.atlassian.net/rest/api/2/filter/10000"
195
+ },
196
+ "subQuery":{
197
+ "query":"resolution = EMPTY OR resolution != EMPTY AND resolutiondate >= -5d"
198
+ },
199
+ "columnConfig":{
200
+ "columns":[
201
+ {
202
+ "name":"Backlog",
203
+ "statuses":[
204
+ {
205
+ "id":"10000",
206
+ "self":"https://mycompany.atlassian.net/rest/api/2/status/10000"
207
+ }
208
+ ]
209
+ }
210
+ ],
211
+ "constraintType":"issueCount"
212
+ },
213
+ "ranking":{
214
+ "rankCustomFieldId":10011
215
+ }
216
+ }
217
+ eos
218
+ allow(response).to receive(:body).and_return(api_json)
219
+ allow(board).to receive(:id).and_return(84)
220
+ expect(client).to receive(:get).with('/rest/agile/1.0/board/84/configuration').and_return(response)
221
+ expect(client).to receive(:BoardConfiguration).and_return(JIRA::Resource::BoardConfigurationFactory.new(client))
222
+ expect(board.configuration).not_to be(nil)
223
+ end
224
+ end