jira-ruby 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +7 -1
- data/Guardfile +1 -1
- data/Rakefile +4 -5
- data/http-basic-example.rb +13 -12
- data/jira-ruby.gemspec +9 -10
- data/lib/jira-ruby.rb +5 -2
- data/lib/jira/base.rb +49 -48
- data/lib/jira/base_factory.rb +1 -4
- data/lib/jira/client.rb +29 -20
- data/lib/jira/has_many_proxy.rb +0 -1
- data/lib/jira/http_client.rb +9 -10
- data/lib/jira/http_error.rb +3 -5
- data/lib/jira/oauth_client.rb +19 -20
- data/lib/jira/request_client.rb +3 -4
- data/lib/jira/resource/agile.rb +10 -8
- data/lib/jira/resource/applinks.rb +5 -8
- data/lib/jira/resource/attachment.rb +1 -2
- data/lib/jira/resource/board.rb +84 -0
- data/lib/jira/resource/comment.rb +0 -2
- data/lib/jira/resource/component.rb +1 -3
- data/lib/jira/resource/createmeta.rb +12 -14
- data/lib/jira/resource/field.rb +22 -22
- data/lib/jira/resource/filter.rb +2 -2
- data/lib/jira/resource/issue.rb +41 -39
- data/lib/jira/resource/issuelink.rb +3 -5
- data/lib/jira/resource/issuelinktype.rb +0 -1
- data/lib/jira/resource/issuetype.rb +1 -3
- data/lib/jira/resource/priority.rb +1 -3
- data/lib/jira/resource/project.rb +5 -7
- data/lib/jira/resource/rapidview.rb +28 -7
- data/lib/jira/resource/remotelink.rb +1 -4
- data/lib/jira/resource/resolution.rb +2 -4
- data/lib/jira/resource/serverinfo.rb +1 -2
- data/lib/jira/resource/sprint.rb +82 -18
- data/lib/jira/resource/sprint_report.rb +8 -0
- data/lib/jira/resource/status.rb +1 -3
- data/lib/jira/resource/transition.rb +2 -6
- data/lib/jira/resource/user.rb +12 -2
- data/lib/jira/resource/version.rb +1 -3
- data/lib/jira/resource/watcher.rb +1 -5
- data/lib/jira/resource/webhook.rb +3 -6
- data/lib/jira/resource/worklog.rb +3 -5
- data/lib/jira/version.rb +1 -1
- data/lib/tasks/generate.rake +4 -4
- data/spec/integration/attachment_spec.rb +15 -16
- data/spec/integration/comment_spec.rb +31 -34
- data/spec/integration/component_spec.rb +21 -24
- data/spec/integration/field_spec.rb +15 -18
- data/spec/integration/issue_spec.rb +44 -48
- data/spec/integration/issuelinktype_spec.rb +8 -11
- data/spec/integration/issuetype_spec.rb +5 -7
- data/spec/integration/priority_spec.rb +5 -8
- data/spec/integration/project_spec.rb +13 -20
- data/spec/integration/rapidview_spec.rb +17 -10
- data/spec/integration/resolution_spec.rb +7 -10
- data/spec/integration/status_spec.rb +5 -8
- data/spec/integration/transition_spec.rb +17 -20
- data/spec/integration/user_spec.rb +24 -8
- data/spec/integration/version_spec.rb +21 -25
- data/spec/integration/watcher_spec.rb +28 -34
- data/spec/integration/webhook.rb +8 -17
- data/spec/integration/worklog_spec.rb +30 -34
- data/spec/jira/base_factory_spec.rb +11 -12
- data/spec/jira/base_spec.rb +204 -228
- data/spec/jira/client_spec.rb +26 -28
- data/spec/jira/has_many_proxy_spec.rb +11 -12
- data/spec/jira/http_client_spec.rb +51 -52
- data/spec/jira/http_error_spec.rb +7 -9
- data/spec/jira/oauth_client_spec.rb +44 -46
- data/spec/jira/request_client_spec.rb +5 -5
- data/spec/jira/resource/agile_spec.rb +5 -7
- data/spec/jira/resource/attachment_spec.rb +25 -26
- data/spec/jira/resource/board_spec.rb +175 -0
- data/spec/jira/resource/createmeta_spec.rb +29 -32
- data/spec/jira/resource/field_spec.rb +42 -48
- data/spec/jira/resource/filter_spec.rb +40 -40
- data/spec/jira/resource/issue_spec.rb +87 -89
- data/spec/jira/resource/issuelink_spec.rb +1 -1
- data/spec/jira/resource/project_factory_spec.rb +2 -4
- data/spec/jira/resource/project_spec.rb +33 -33
- data/spec/jira/resource/sprint_spec.rb +78 -0
- data/spec/jira/resource/user_factory_spec.rb +6 -8
- data/spec/jira/resource/worklog_spec.rb +9 -11
- data/spec/spec_helper.rb +8 -9
- data/spec/support/clients_helper.rb +4 -4
- data/spec/support/shared_examples/integration.rb +60 -77
- metadata +59 -53
@@ -1,158 +1,157 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe JIRA::Resource::Issue do
|
4
|
-
|
5
4
|
class JIRAResourceDelegation < SimpleDelegator # :nodoc:
|
6
5
|
end
|
7
6
|
|
8
7
|
let(:client) do
|
9
|
-
client = double(options: {rest_base_path: '/jira/rest/api/2'}
|
8
|
+
client = double(options: { rest_base_path: '/jira/rest/api/2' })
|
10
9
|
allow(client).to receive(:Field).and_return(JIRA::Resource::FieldFactory.new(client))
|
11
10
|
allow(client).to receive(:cache).and_return(OpenStruct.new)
|
12
11
|
client
|
13
12
|
end
|
14
13
|
|
15
|
-
describe
|
16
|
-
describe
|
14
|
+
describe '#respond_to?' do
|
15
|
+
describe 'when decorated by SimpleDelegator' do
|
17
16
|
before(:each) do
|
18
|
-
response = double
|
17
|
+
response = double
|
19
18
|
allow(response).to receive(:body).and_return('{"key":"foo","id":"101"}')
|
20
19
|
allow(JIRA::Resource::Issue).to receive(:collection_path).and_return('/jira/rest/api/2/issue')
|
21
|
-
allow(client).to receive(:get).with('/jira/rest/api/2/issue/101')
|
22
|
-
|
20
|
+
allow(client).to receive(:get).with('/jira/rest/api/2/issue/101')
|
21
|
+
.and_return(response)
|
23
22
|
|
24
|
-
issue = JIRA::Resource::Issue.find(client,101)
|
25
|
-
@decorated = JIRAResourceDelegation.new(
|
23
|
+
issue = JIRA::Resource::Issue.find(client, 101)
|
24
|
+
@decorated = JIRAResourceDelegation.new(issue)
|
26
25
|
end
|
27
|
-
it
|
26
|
+
it 'responds to key' do
|
28
27
|
expect(@decorated.respond_to?(:key)).to eq(true)
|
29
28
|
end
|
30
|
-
it
|
31
|
-
expect
|
29
|
+
it 'does not raise an error' do
|
30
|
+
expect do
|
32
31
|
@issue.respond_to?(:project)
|
33
|
-
|
32
|
+
end.not_to raise_error
|
34
33
|
end
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
38
|
-
it
|
39
|
-
response = double
|
40
|
-
empty_response = double
|
41
|
-
issue = double
|
37
|
+
it 'should find all issues' do
|
38
|
+
response = double
|
39
|
+
empty_response = double
|
40
|
+
issue = double
|
42
41
|
|
43
42
|
allow(response).to receive(:body).and_return('{"issues":[{"id":"1","summary":"Bugs Everywhere"}]}')
|
44
|
-
expect(client).to receive(:get).with('/jira/rest/api/2/search?expand=transitions.fields&maxResults=1000&startAt=0')
|
45
|
-
|
43
|
+
expect(client).to receive(:get).with('/jira/rest/api/2/search?expand=transitions.fields&maxResults=1000&startAt=0')
|
44
|
+
.and_return(response)
|
46
45
|
allow(empty_response).to receive(:body).and_return('{"issues":[]}')
|
47
|
-
expect(client).to receive(:get).with('/jira/rest/api/2/search?expand=transitions.fields&maxResults=1000&startAt=1')
|
48
|
-
|
49
|
-
|
46
|
+
expect(client).to receive(:get).with('/jira/rest/api/2/search?expand=transitions.fields&maxResults=1000&startAt=1')
|
47
|
+
.and_return(empty_response)
|
48
|
+
|
50
49
|
expect(client).to receive(:Issue).and_return(issue)
|
51
|
-
expect(issue).to receive(:build).with(
|
50
|
+
expect(issue).to receive(:build).with('id' => '1', 'summary' => 'Bugs Everywhere')
|
52
51
|
|
53
52
|
issues = JIRA::Resource::Issue.all(client)
|
54
53
|
end
|
55
54
|
|
56
|
-
it
|
57
|
-
response = double
|
55
|
+
it 'should find an issue by key or id' do
|
56
|
+
response = double
|
58
57
|
|
59
58
|
allow(response).to receive(:body).and_return('{"key":"foo","id":"101"}')
|
60
59
|
allow(JIRA::Resource::Issue).to receive(:collection_path).and_return('/jira/rest/api/2/issue')
|
61
|
-
expect(client).to receive(:get).with('/jira/rest/api/2/issue/foo')
|
62
|
-
|
63
|
-
expect(client).to receive(:get).with('/jira/rest/api/2/issue/101')
|
64
|
-
|
60
|
+
expect(client).to receive(:get).with('/jira/rest/api/2/issue/foo')
|
61
|
+
.and_return(response)
|
62
|
+
expect(client).to receive(:get).with('/jira/rest/api/2/issue/101')
|
63
|
+
.and_return(response)
|
65
64
|
|
66
|
-
issue_from_id = JIRA::Resource::Issue.find(client,101)
|
67
|
-
issue_from_key = JIRA::Resource::Issue.find(client,'foo')
|
65
|
+
issue_from_id = JIRA::Resource::Issue.find(client, 101)
|
66
|
+
issue_from_key = JIRA::Resource::Issue.find(client, 'foo')
|
68
67
|
|
69
68
|
expect(issue_from_id.attrs).to eq(issue_from_key.attrs)
|
70
69
|
end
|
71
70
|
|
72
|
-
it
|
73
|
-
response = double
|
74
|
-
issue = double
|
71
|
+
it 'should search an issue with a jql query string' do
|
72
|
+
response = double
|
73
|
+
issue = double
|
75
74
|
|
76
75
|
allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}')
|
77
|
-
expect(client).to receive(:get).with('/jira/rest/api/2/search?jql=foo+bar')
|
78
|
-
|
76
|
+
expect(client).to receive(:get).with('/jira/rest/api/2/search?jql=foo+bar')
|
77
|
+
.and_return(response)
|
79
78
|
expect(client).to receive(:Issue).and_return(issue)
|
80
|
-
expect(issue).to receive(:build).with([
|
79
|
+
expect(issue).to receive(:build).with(%w[key foo]).and_return('')
|
81
80
|
|
82
|
-
expect(JIRA::Resource::Issue.jql(client,'foo bar')).to eq([''])
|
81
|
+
expect(JIRA::Resource::Issue.jql(client, 'foo bar')).to eq([''])
|
83
82
|
end
|
84
83
|
|
85
|
-
it
|
86
|
-
response = double
|
87
|
-
issue = double
|
84
|
+
it 'should search an issue with a jql query string and fields' do
|
85
|
+
response = double
|
86
|
+
issue = double
|
88
87
|
|
89
88
|
allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}')
|
90
89
|
expect(client).to receive(:get)
|
91
90
|
.with('/jira/rest/api/2/search?jql=foo+bar&fields=foo,bar')
|
92
91
|
.and_return(response)
|
93
92
|
expect(client).to receive(:Issue).and_return(issue)
|
94
|
-
expect(issue).to receive(:build).with([
|
93
|
+
expect(issue).to receive(:build).with(%w[key foo]).and_return('')
|
95
94
|
|
96
|
-
expect(JIRA::Resource::Issue.jql(client, 'foo bar', fields: [
|
95
|
+
expect(JIRA::Resource::Issue.jql(client, 'foo bar', fields: %w[foo bar])).to eq([''])
|
97
96
|
end
|
98
97
|
|
99
|
-
it
|
100
|
-
response = double
|
101
|
-
issue = double
|
98
|
+
it 'should search an issue with a jql query string, start at, and maxResults' do
|
99
|
+
response = double
|
100
|
+
issue = double
|
102
101
|
|
103
102
|
allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}')
|
104
103
|
expect(client).to receive(:get)
|
105
104
|
.with('/jira/rest/api/2/search?jql=foo+bar&startAt=1&maxResults=3')
|
106
105
|
.and_return(response)
|
107
106
|
expect(client).to receive(:Issue).and_return(issue)
|
108
|
-
expect(issue).to receive(:build).with([
|
107
|
+
expect(issue).to receive(:build).with(%w[key foo]).and_return('')
|
109
108
|
|
110
|
-
expect(JIRA::Resource::Issue.jql(client,'foo bar', start_at: 1, max_results: 3)).to eq([''])
|
109
|
+
expect(JIRA::Resource::Issue.jql(client, 'foo bar', start_at: 1, max_results: 3)).to eq([''])
|
111
110
|
end
|
112
111
|
|
113
|
-
it
|
114
|
-
response = double
|
115
|
-
issue = double
|
112
|
+
it 'should search an issue with a jql query string and maxResults equals zero and should return the count of tickets' do
|
113
|
+
response = double
|
114
|
+
issue = double
|
116
115
|
|
117
116
|
allow(response).to receive(:body).and_return('{"total": 1, "issues": []}')
|
118
117
|
expect(client).to receive(:get)
|
119
118
|
.with('/jira/rest/api/2/search?jql=foo+bar&maxResults=0')
|
120
119
|
.and_return(response)
|
121
120
|
|
122
|
-
expect(JIRA::Resource::Issue.jql(client,'foo bar', max_results: 0)).to eq(1)
|
121
|
+
expect(JIRA::Resource::Issue.jql(client, 'foo bar', max_results: 0)).to eq(1)
|
123
122
|
end
|
124
123
|
|
125
|
-
it
|
126
|
-
response = double
|
127
|
-
issue = double
|
124
|
+
it 'should search an issue with a jql query string and string expand' do
|
125
|
+
response = double
|
126
|
+
issue = double
|
128
127
|
|
129
128
|
allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}')
|
130
129
|
expect(client).to receive(:get)
|
131
130
|
.with('/jira/rest/api/2/search?jql=foo+bar&expand=transitions')
|
132
131
|
.and_return(response)
|
133
132
|
expect(client).to receive(:Issue).and_return(issue)
|
134
|
-
expect(issue).to receive(:build).with([
|
133
|
+
expect(issue).to receive(:build).with(%w[key foo]).and_return('')
|
135
134
|
|
136
|
-
expect(JIRA::Resource::Issue.jql(client,'foo bar', expand: 'transitions')).to eq([''])
|
135
|
+
expect(JIRA::Resource::Issue.jql(client, 'foo bar', expand: 'transitions')).to eq([''])
|
137
136
|
end
|
138
137
|
|
139
|
-
it
|
140
|
-
response = double
|
141
|
-
issue = double
|
138
|
+
it 'should search an issue with a jql query string and array expand' do
|
139
|
+
response = double
|
140
|
+
issue = double
|
142
141
|
|
143
142
|
allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}')
|
144
143
|
expect(client).to receive(:get)
|
145
144
|
.with('/jira/rest/api/2/search?jql=foo+bar&expand=transitions')
|
146
145
|
.and_return(response)
|
147
146
|
expect(client).to receive(:Issue).and_return(issue)
|
148
|
-
expect(issue).to receive(:build).with([
|
147
|
+
expect(issue).to receive(:build).with(%w[key foo]).and_return('')
|
149
148
|
|
150
|
-
expect(JIRA::Resource::Issue.jql(client,'foo bar', expand: %w
|
149
|
+
expect(JIRA::Resource::Issue.jql(client, 'foo bar', expand: %w[transitions])).to eq([''])
|
151
150
|
end
|
152
151
|
|
153
152
|
it 'should return meta data available for editing an issue' do
|
154
|
-
subject = JIRA::Resource::Issue.new(client, :
|
155
|
-
response = double
|
153
|
+
subject = JIRA::Resource::Issue.new(client, attrs: { 'fields' => { 'key' => 'TST=123' } })
|
154
|
+
response = double
|
156
155
|
|
157
156
|
allow(response).to receive(:body).and_return(
|
158
157
|
'{"fields":{"summary":{"required":true,"name":"Summary","operations":["set"]}}}'
|
@@ -161,37 +160,36 @@ describe JIRA::Resource::Issue do
|
|
161
160
|
.with('/jira/rest/api/2/issue/TST=123/editmeta')
|
162
161
|
.and_return(response)
|
163
162
|
|
164
|
-
expect(subject.editmeta).to eq(
|
163
|
+
expect(subject.editmeta).to eq('summary' => { 'required' => true, 'name' => 'Summary', 'operations' => ['set'] })
|
165
164
|
end
|
166
165
|
|
167
|
-
|
168
|
-
|
169
|
-
subject = JIRA::Resource::Issue.new(client, :attrs => {'fields' => {'foo' =>'bar'}})
|
166
|
+
it 'provides direct accessors to the fields' do
|
167
|
+
subject = JIRA::Resource::Issue.new(client, attrs: { 'fields' => { 'foo' => 'bar' } })
|
170
168
|
expect(subject).to respond_to(:foo)
|
171
169
|
expect(subject.foo).to eq('bar')
|
172
170
|
end
|
173
171
|
|
174
|
-
describe
|
175
|
-
subject
|
176
|
-
JIRA::Resource::Issue.new(client, :
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
it
|
172
|
+
describe 'relationships' do
|
173
|
+
subject do
|
174
|
+
JIRA::Resource::Issue.new(client, attrs: {
|
175
|
+
'id' => '123',
|
176
|
+
'fields' => {
|
177
|
+
'reporter' => { 'foo' => 'bar' },
|
178
|
+
'assignee' => { 'foo' => 'bar' },
|
179
|
+
'project' => { 'foo' => 'bar' },
|
180
|
+
'priority' => { 'foo' => 'bar' },
|
181
|
+
'issuetype' => { 'foo' => 'bar' },
|
182
|
+
'status' => { 'foo' => 'bar' },
|
183
|
+
'components' => [{ 'foo' => 'bar' }, { 'baz' => 'flum' }],
|
184
|
+
'versions' => [{ 'foo' => 'bar' }, { 'baz' => 'flum' }],
|
185
|
+
'comment' => { 'comments' => [{ 'foo' => 'bar' }, { 'baz' => 'flum' }] },
|
186
|
+
'attachment' => [{ 'foo' => 'bar' }, { 'baz' => 'flum' }],
|
187
|
+
'worklog' => { 'worklogs' => [{ 'foo' => 'bar' }, { 'baz' => 'flum' }] }
|
188
|
+
}
|
189
|
+
})
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'has the correct relationships' do
|
195
193
|
expect(subject).to have_one(:reporter, JIRA::Resource::User)
|
196
194
|
expect(subject.reporter.foo).to eq('bar')
|
197
195
|
|
@@ -1,13 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe JIRA::Resource::ProjectFactory do
|
4
|
-
|
5
|
-
let(:client) { double() }
|
4
|
+
let(:client) { double }
|
6
5
|
subject { JIRA::Resource::ProjectFactory.new(client) }
|
7
6
|
|
8
|
-
it
|
7
|
+
it 'initializes correctly' do
|
9
8
|
expect(subject.class).to eq(JIRA::Resource::ProjectFactory)
|
10
9
|
expect(subject.client).to eq(client)
|
11
10
|
end
|
12
|
-
|
13
11
|
end
|
@@ -1,22 +1,22 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe JIRA::Resource::Project do
|
4
|
+
let(:client) do
|
5
|
+
double('client', options: {
|
6
|
+
rest_base_path: '/jira/rest/api/2'
|
7
|
+
})
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'relationships' do
|
11
|
+
subject do
|
12
|
+
JIRA::Resource::Project.new(client, attrs: {
|
13
|
+
'lead' => { 'foo' => 'bar' },
|
14
|
+
'issueTypes' => [{ 'foo' => 'bar' }, { 'baz' => 'flum' }],
|
15
|
+
'versions' => [{ 'foo' => 'bar' }, { 'baz' => 'flum' }]
|
16
|
+
})
|
17
|
+
end
|
4
18
|
|
5
|
-
|
6
|
-
:rest_base_path => '/jira/rest/api/2'
|
7
|
-
})
|
8
|
-
}
|
9
|
-
|
10
|
-
describe "relationships" do
|
11
|
-
subject {
|
12
|
-
JIRA::Resource::Project.new(client, :attrs => {
|
13
|
-
'lead' => {'foo' => 'bar'},
|
14
|
-
'issueTypes' => [{'foo' =>'bar'},{'baz' => 'flum'}],
|
15
|
-
'versions' => [{'foo' =>'bar'},{'baz' => 'flum'}],
|
16
|
-
})
|
17
|
-
}
|
18
|
-
|
19
|
-
it "has the correct relationships" do
|
19
|
+
it 'has the correct relationships' do
|
20
20
|
expect(subject).to have_one(:lead, JIRA::Resource::User)
|
21
21
|
expect(subject.lead.foo).to eq('bar')
|
22
22
|
|
@@ -28,42 +28,42 @@ describe JIRA::Resource::Project do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
describe
|
32
|
-
subject
|
33
|
-
JIRA::Resource::Project.new(client, :
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
describe 'issues' do
|
32
|
+
subject do
|
33
|
+
JIRA::Resource::Project.new(client, attrs: {
|
34
|
+
'key' => 'test'
|
35
|
+
})
|
36
|
+
end
|
37
37
|
|
38
|
-
it
|
38
|
+
it 'returns issues' do
|
39
39
|
response_body = '{"expand":"schema,names","startAt":0,"maxResults":1,"total":1,"issues":[{"expand":"editmeta,renderedFields,transitions,changelog,operations","id":"53062","self":"/rest/api/2/issue/53062","key":"test key","fields":{"summary":"test summary"}}]}'
|
40
|
-
response = double(
|
41
|
-
|
42
|
-
issue_factory = double(
|
40
|
+
response = double('response',
|
41
|
+
body: response_body)
|
42
|
+
issue_factory = double('issue factory')
|
43
43
|
|
44
44
|
expect(client).to receive(:get)
|
45
45
|
.with('/jira/rest/api/2/search?jql=project%3D%22test%22')
|
46
46
|
.and_return(response)
|
47
47
|
expect(client).to receive(:Issue).and_return(issue_factory)
|
48
48
|
expect(issue_factory).to receive(:build)
|
49
|
-
.with(JSON.parse(response_body)[
|
49
|
+
.with(JSON.parse(response_body)['issues'][0])
|
50
50
|
subject.issues
|
51
51
|
end
|
52
52
|
|
53
|
-
context
|
54
|
-
it
|
53
|
+
context 'with changelog' do
|
54
|
+
it 'returns issues' do
|
55
55
|
response_body = '{"expand":"schema,names","startAt":0,"maxResults":1,"total":1,"issues":[{"expand":"editmeta,renderedFields,transitions,changelog,operations","id":"53062","self":"/rest/api/2/issue/53062","key":"test key","fields":{"summary":"test summary"},"changelog":{}}]}'
|
56
|
-
response = double(
|
57
|
-
|
58
|
-
issue_factory = double(
|
56
|
+
response = double('response',
|
57
|
+
body: response_body)
|
58
|
+
issue_factory = double('issue factory')
|
59
59
|
|
60
60
|
expect(client).to receive(:get)
|
61
61
|
.with('/jira/rest/api/2/search?jql=project%3D%22test%22&expand=changelog&startAt=1&maxResults=100')
|
62
62
|
.and_return(response)
|
63
63
|
expect(client).to receive(:Issue).and_return(issue_factory)
|
64
64
|
expect(issue_factory).to receive(:build)
|
65
|
-
.with(JSON.parse(response_body)[
|
66
|
-
subject.issues(
|
65
|
+
.with(JSON.parse(response_body)['issues'][0])
|
66
|
+
subject.issues(expand: 'changelog', startAt: 1, maxResults: 100)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JIRA::Resource::Sprint do
|
4
|
+
describe 'peristence' do
|
5
|
+
let(:sprint) { described_class.new(client) }
|
6
|
+
let(:client) { double('Client', options: { site: 'https://foo.bar.com' }) }
|
7
|
+
|
8
|
+
describe '#save' do
|
9
|
+
let(:agile_sprint_url) { "#{sprint.client.options[:site]}/rest/agile/1.0/sprint/#{sprint.id}" }
|
10
|
+
let(:instance_attrs) { { start_date: '2016-06-01' } }
|
11
|
+
|
12
|
+
before do
|
13
|
+
sprint.attrs = instance_attrs
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when attributes are specified' do
|
17
|
+
let(:given_attrs) { { start_date: '2016-06-10' } }
|
18
|
+
|
19
|
+
it 'calls save on the super class with the given attributes & agile url' do
|
20
|
+
expect_any_instance_of(JIRA::Base).to receive(:save).with(given_attrs, agile_sprint_url)
|
21
|
+
|
22
|
+
sprint.save(given_attrs)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when attributes are not specified' do
|
27
|
+
it 'calls save on the super class with the instance attributes & agile url' do
|
28
|
+
expect_any_instance_of(JIRA::Base).to receive(:save).with(instance_attrs, agile_sprint_url)
|
29
|
+
|
30
|
+
sprint.save
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when providing the path argument' do
|
35
|
+
it 'ignores it' do
|
36
|
+
expect_any_instance_of(JIRA::Base).to receive(:save).with(instance_attrs, agile_sprint_url)
|
37
|
+
|
38
|
+
sprint.save({}, 'mavenlink.com')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#save!' do
|
44
|
+
let(:agile_sprint_url) { "#{sprint.client.options[:site]}/rest/agile/1.0/sprint/#{sprint.id}" }
|
45
|
+
let(:instance_attrs) { { start_date: '2016-06-01' } }
|
46
|
+
|
47
|
+
before do
|
48
|
+
sprint.attrs = instance_attrs
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'when attributes are specified' do
|
52
|
+
let(:given_attrs) { { start_date: '2016-06-10' } }
|
53
|
+
|
54
|
+
it 'calls save! on the super class with the given attributes & agile url' do
|
55
|
+
expect_any_instance_of(JIRA::Base).to receive(:save!).with(given_attrs, agile_sprint_url)
|
56
|
+
|
57
|
+
sprint.save!(given_attrs)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'when attributes are not specified' do
|
62
|
+
it 'calls save! on the super class with the instance attributes & agile url' do
|
63
|
+
expect_any_instance_of(JIRA::Base).to receive(:save!).with(instance_attrs, agile_sprint_url)
|
64
|
+
|
65
|
+
sprint.save!
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when providing the path argument' do
|
70
|
+
it 'ignores it' do
|
71
|
+
expect_any_instance_of(JIRA::Base).to receive(:save!).with(instance_attrs, agile_sprint_url)
|
72
|
+
|
73
|
+
sprint.save!({}, 'mavenlink.com')
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|