jira-ruby 1.7.1 → 2.1.2

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.
@@ -1,6 +1,14 @@
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
11
+
4
12
  let(:client) do
5
13
  double(
6
14
  'client',
@@ -17,42 +25,78 @@ describe JIRA::Resource::Attachment do
17
25
  end
18
26
 
19
27
  describe 'relationships' do
20
- subject do
21
- JIRA::Resource::Attachment.new(client,
22
- issue: JIRA::Resource::Issue.new(client),
23
- attrs: { 'author' => { 'foo' => 'bar' } })
28
+ it 'has an author' do
29
+ expect(subject).to have_one(:author, JIRA::Resource::User)
24
30
  end
25
31
 
26
- it 'has the correct relationships' do
27
- expect(subject).to have_one(:author, JIRA::Resource::User)
32
+ it 'has the correct author name' do
28
33
  expect(subject.author.foo).to eq('bar')
29
34
  end
30
35
  end
31
36
 
32
- describe '#meta' do
37
+ describe '.meta' do
38
+ subject { JIRA::Resource::Attachment.meta(client) }
39
+
33
40
  let(:response) do
34
41
  double(
35
- 'response',
36
- body: '{"enabled":true,"uploadLimit":10485760}'
42
+ 'response',
43
+ body: '{"enabled":true,"uploadLimit":10485760}'
37
44
  )
38
45
  end
39
46
 
40
47
  it 'returns meta information about attachment upload' do
41
48
  expect(client).to receive(:get).with('/jira/rest/api/2/attachment/meta').and_return(response)
42
- JIRA::Resource::Attachment.meta(client)
49
+
50
+ subject
43
51
  end
44
52
 
45
- subject { JIRA::Resource::AttachmentFactory.new(client) }
53
+ context 'the factory delegates correctly' do
54
+ subject { JIRA::Resource::AttachmentFactory.new(client) }
46
55
 
47
- it 'delegates #meta to to target class' do
48
- expect(subject).to respond_to(:meta)
56
+ it 'delegates #meta to to target class' do
57
+ expect(subject).to respond_to(:meta)
58
+ end
49
59
  end
50
60
  end
51
61
 
52
- describe '#save!' do
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
+
53
85
  it 'successfully update the attachment' do
54
- basic_auth_http_conn = double
55
- response = double(
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(
56
100
  body: [
57
101
  {
58
102
  "id": 10_001,
@@ -64,18 +108,31 @@ describe JIRA::Resource::Attachment do
64
108
  }
65
109
  ].to_json
66
110
  )
111
+ end
112
+ let(:issue) { JIRA::Resource::Issue.new(client) }
67
113
 
68
- allow(client.request_client).to receive(:basic_auth_http_conn).and_return(basic_auth_http_conn)
69
- allow(basic_auth_http_conn).to receive(:request).and_return(response)
114
+ before do
115
+ allow(client).to receive(:post_multipart).and_return(response)
116
+ end
70
117
 
71
- issue = JIRA::Resource::Issue.new(client)
72
- path_to_file = './spec/mock_responses/issue.json'
73
- attachment = JIRA::Resource::Attachment.new(client, issue: issue)
74
- attachment.save!('file' => path_to_file)
118
+ it 'successfully update the attachment' do
119
+ subject
75
120
 
76
121
  expect(attachment.filename).to eq 'picture.jpg'
77
122
  expect(attachment.mimeType).to eq 'image/jpeg'
78
123
  expect(attachment.size).to eq 23_123
79
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
80
137
  end
81
138
  end
@@ -172,4 +172,53 @@ eos
172
172
  expect(client).to receive(:Sprint).twice.and_return(JIRA::Resource::SprintFactory.new(client))
173
173
  expect(board.sprints.size).to be(2)
174
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
175
224
  end
@@ -1,12 +1,25 @@
1
1
  require 'spec_helper'
2
2
 
3
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' }) }
4
+ let(:client) do
5
+ client = double(options: { site: 'https://foo.bar.com', context_path: '/jira' })
6
+ allow(client).to receive(:Sprint).and_return(JIRA::Resource::SprintFactory.new(client))
7
+ client
8
+ end
9
+ let(:sprint) { described_class.new(client) }
10
+ let(:agile_sprint_path) { "#{sprint.client.options[:context_path]}/rest/agile/1.0/sprint/#{sprint.id}" }
7
11
 
12
+ describe '::find' do
13
+ let(:response) { double('Response', body: '{"some_detail":"some detail"}') }
14
+
15
+ it 'fetches the sprint from JIRA' do
16
+ expect(client).to receive(:get).with('/jira/rest/agile/1.0/sprint/111').and_return(response)
17
+ expect(JIRA::Resource::Sprint.find(client, '111')).to be_a(JIRA::Resource::Sprint)
18
+ end
19
+ end
20
+
21
+ describe 'peristence' do
8
22
  describe '#save' do
9
- let(:agile_sprint_url) { "#{sprint.client.options[:site]}/rest/agile/1.0/sprint/#{sprint.id}" }
10
23
  let(:instance_attrs) { { start_date: '2016-06-01' } }
11
24
 
12
25
  before do
@@ -17,7 +30,7 @@ describe JIRA::Resource::Sprint do
17
30
  let(:given_attrs) { { start_date: '2016-06-10' } }
18
31
 
19
32
  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)
33
+ expect_any_instance_of(JIRA::Base).to receive(:save).with(given_attrs, agile_sprint_path)
21
34
 
22
35
  sprint.save(given_attrs)
23
36
  end
@@ -25,7 +38,7 @@ describe JIRA::Resource::Sprint do
25
38
 
26
39
  context 'when attributes are not specified' do
27
40
  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)
41
+ expect_any_instance_of(JIRA::Base).to receive(:save).with(instance_attrs, agile_sprint_path)
29
42
 
30
43
  sprint.save
31
44
  end
@@ -33,7 +46,7 @@ describe JIRA::Resource::Sprint do
33
46
 
34
47
  context 'when providing the path argument' do
35
48
  it 'ignores it' do
36
- expect_any_instance_of(JIRA::Base).to receive(:save).with(instance_attrs, agile_sprint_url)
49
+ expect_any_instance_of(JIRA::Base).to receive(:save).with(instance_attrs, agile_sprint_path)
37
50
 
38
51
  sprint.save({}, 'mavenlink.com')
39
52
  end
@@ -41,7 +54,6 @@ describe JIRA::Resource::Sprint do
41
54
  end
42
55
 
43
56
  describe '#save!' do
44
- let(:agile_sprint_url) { "#{sprint.client.options[:site]}/rest/agile/1.0/sprint/#{sprint.id}" }
45
57
  let(:instance_attrs) { { start_date: '2016-06-01' } }
46
58
 
47
59
  before do
@@ -52,7 +64,7 @@ describe JIRA::Resource::Sprint do
52
64
  let(:given_attrs) { { start_date: '2016-06-10' } }
53
65
 
54
66
  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)
67
+ expect_any_instance_of(JIRA::Base).to receive(:save!).with(given_attrs, agile_sprint_path)
56
68
 
57
69
  sprint.save!(given_attrs)
58
70
  end
@@ -60,7 +72,7 @@ describe JIRA::Resource::Sprint do
60
72
 
61
73
  context 'when attributes are not specified' do
62
74
  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)
75
+ expect_any_instance_of(JIRA::Base).to receive(:save!).with(instance_attrs, agile_sprint_path)
64
76
 
65
77
  sprint.save!
66
78
  end
@@ -68,7 +80,7 @@ describe JIRA::Resource::Sprint do
68
80
 
69
81
  context 'when providing the path argument' do
70
82
  it 'ignores it' do
71
- expect_any_instance_of(JIRA::Base).to receive(:save!).with(instance_attrs, agile_sprint_url)
83
+ expect_any_instance_of(JIRA::Base).to receive(:save!).with(instance_attrs, agile_sprint_path)
72
84
 
73
85
  sprint.save!({}, 'mavenlink.com')
74
86
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jira-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - SUMO Heavy Industries
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-08-19 00:00:00.000000000 Z
12
+ date: 2020-07-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -57,42 +57,42 @@ dependencies:
57
57
  name: oauth
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: '0.5'
63
60
  - - ">="
64
61
  - !ruby/object:Gem::Version
65
62
  version: 0.5.0
63
+ - - "~>"
64
+ - !ruby/object:Gem::Version
65
+ version: '0.5'
66
66
  type: :runtime
67
67
  prerelease: false
68
68
  version_requirements: !ruby/object:Gem::Requirement
69
69
  requirements:
70
- - - "~>"
71
- - !ruby/object:Gem::Version
72
- version: '0.5'
73
70
  - - ">="
74
71
  - !ruby/object:Gem::Version
75
72
  version: 0.5.0
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.5'
76
76
  - !ruby/object:Gem::Dependency
77
77
  name: guard
78
78
  requirement: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '2.13'
83
80
  - - ">="
84
81
  - !ruby/object:Gem::Version
85
82
  version: 2.13.0
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '2.13'
86
86
  type: :development
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - "~>"
91
- - !ruby/object:Gem::Version
92
- version: '2.13'
93
90
  - - ">="
94
91
  - !ruby/object:Gem::Version
95
92
  version: 2.13.0
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '2.13'
96
96
  - !ruby/object:Gem::Dependency
97
97
  name: guard-rspec
98
98
  requirement: !ruby/object:Gem::Requirement
@@ -171,42 +171,42 @@ dependencies:
171
171
  name: rspec
172
172
  requirement: !ruby/object:Gem::Requirement
173
173
  requirements:
174
- - - "~>"
175
- - !ruby/object:Gem::Version
176
- version: '3.0'
177
174
  - - ">="
178
175
  - !ruby/object:Gem::Version
179
176
  version: 3.0.0
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '3.0'
180
180
  type: :development
181
181
  prerelease: false
182
182
  version_requirements: !ruby/object:Gem::Requirement
183
183
  requirements:
184
- - - "~>"
185
- - !ruby/object:Gem::Version
186
- version: '3.0'
187
184
  - - ">="
188
185
  - !ruby/object:Gem::Version
189
186
  version: 3.0.0
187
+ - - "~>"
188
+ - !ruby/object:Gem::Version
189
+ version: '3.0'
190
190
  - !ruby/object:Gem::Dependency
191
191
  name: webmock
192
192
  requirement: !ruby/object:Gem::Requirement
193
193
  requirements:
194
- - - "~>"
195
- - !ruby/object:Gem::Version
196
- version: '1.18'
197
194
  - - ">="
198
195
  - !ruby/object:Gem::Version
199
196
  version: 1.18.0
197
+ - - "~>"
198
+ - !ruby/object:Gem::Version
199
+ version: '1.18'
200
200
  type: :development
201
201
  prerelease: false
202
202
  version_requirements: !ruby/object:Gem::Requirement
203
203
  requirements:
204
- - - "~>"
205
- - !ruby/object:Gem::Version
206
- version: '1.18'
207
204
  - - ">="
208
205
  - !ruby/object:Gem::Version
209
206
  version: 1.18.0
207
+ - - "~>"
208
+ - !ruby/object:Gem::Version
209
+ version: '1.18'
210
210
  description: API for JIRA
211
211
  email:
212
212
  executables: []
@@ -238,6 +238,7 @@ files:
238
238
  - lib/jira/resource/applinks.rb
239
239
  - lib/jira/resource/attachment.rb
240
240
  - lib/jira/resource/board.rb
241
+ - lib/jira/resource/board_configuration.rb
241
242
  - lib/jira/resource/comment.rb
242
243
  - lib/jira/resource/component.rb
243
244
  - lib/jira/resource/createmeta.rb
@@ -384,8 +385,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
384
385
  - !ruby/object:Gem::Version
385
386
  version: '0'
386
387
  requirements: []
387
- rubyforge_project:
388
- rubygems_version: 2.7.6
388
+ rubygems_version: 3.0.3
389
389
  signing_key:
390
390
  specification_version: 4
391
391
  summary: Ruby Gem for use with the Atlassian JIRA REST API