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.
Files changed (88) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +7 -1
  3. data/Guardfile +1 -1
  4. data/Rakefile +4 -5
  5. data/http-basic-example.rb +13 -12
  6. data/jira-ruby.gemspec +9 -10
  7. data/lib/jira-ruby.rb +5 -2
  8. data/lib/jira/base.rb +49 -48
  9. data/lib/jira/base_factory.rb +1 -4
  10. data/lib/jira/client.rb +29 -20
  11. data/lib/jira/has_many_proxy.rb +0 -1
  12. data/lib/jira/http_client.rb +9 -10
  13. data/lib/jira/http_error.rb +3 -5
  14. data/lib/jira/oauth_client.rb +19 -20
  15. data/lib/jira/request_client.rb +3 -4
  16. data/lib/jira/resource/agile.rb +10 -8
  17. data/lib/jira/resource/applinks.rb +5 -8
  18. data/lib/jira/resource/attachment.rb +1 -2
  19. data/lib/jira/resource/board.rb +84 -0
  20. data/lib/jira/resource/comment.rb +0 -2
  21. data/lib/jira/resource/component.rb +1 -3
  22. data/lib/jira/resource/createmeta.rb +12 -14
  23. data/lib/jira/resource/field.rb +22 -22
  24. data/lib/jira/resource/filter.rb +2 -2
  25. data/lib/jira/resource/issue.rb +41 -39
  26. data/lib/jira/resource/issuelink.rb +3 -5
  27. data/lib/jira/resource/issuelinktype.rb +0 -1
  28. data/lib/jira/resource/issuetype.rb +1 -3
  29. data/lib/jira/resource/priority.rb +1 -3
  30. data/lib/jira/resource/project.rb +5 -7
  31. data/lib/jira/resource/rapidview.rb +28 -7
  32. data/lib/jira/resource/remotelink.rb +1 -4
  33. data/lib/jira/resource/resolution.rb +2 -4
  34. data/lib/jira/resource/serverinfo.rb +1 -2
  35. data/lib/jira/resource/sprint.rb +82 -18
  36. data/lib/jira/resource/sprint_report.rb +8 -0
  37. data/lib/jira/resource/status.rb +1 -3
  38. data/lib/jira/resource/transition.rb +2 -6
  39. data/lib/jira/resource/user.rb +12 -2
  40. data/lib/jira/resource/version.rb +1 -3
  41. data/lib/jira/resource/watcher.rb +1 -5
  42. data/lib/jira/resource/webhook.rb +3 -6
  43. data/lib/jira/resource/worklog.rb +3 -5
  44. data/lib/jira/version.rb +1 -1
  45. data/lib/tasks/generate.rake +4 -4
  46. data/spec/integration/attachment_spec.rb +15 -16
  47. data/spec/integration/comment_spec.rb +31 -34
  48. data/spec/integration/component_spec.rb +21 -24
  49. data/spec/integration/field_spec.rb +15 -18
  50. data/spec/integration/issue_spec.rb +44 -48
  51. data/spec/integration/issuelinktype_spec.rb +8 -11
  52. data/spec/integration/issuetype_spec.rb +5 -7
  53. data/spec/integration/priority_spec.rb +5 -8
  54. data/spec/integration/project_spec.rb +13 -20
  55. data/spec/integration/rapidview_spec.rb +17 -10
  56. data/spec/integration/resolution_spec.rb +7 -10
  57. data/spec/integration/status_spec.rb +5 -8
  58. data/spec/integration/transition_spec.rb +17 -20
  59. data/spec/integration/user_spec.rb +24 -8
  60. data/spec/integration/version_spec.rb +21 -25
  61. data/spec/integration/watcher_spec.rb +28 -34
  62. data/spec/integration/webhook.rb +8 -17
  63. data/spec/integration/worklog_spec.rb +30 -34
  64. data/spec/jira/base_factory_spec.rb +11 -12
  65. data/spec/jira/base_spec.rb +204 -228
  66. data/spec/jira/client_spec.rb +26 -28
  67. data/spec/jira/has_many_proxy_spec.rb +11 -12
  68. data/spec/jira/http_client_spec.rb +51 -52
  69. data/spec/jira/http_error_spec.rb +7 -9
  70. data/spec/jira/oauth_client_spec.rb +44 -46
  71. data/spec/jira/request_client_spec.rb +5 -5
  72. data/spec/jira/resource/agile_spec.rb +5 -7
  73. data/spec/jira/resource/attachment_spec.rb +25 -26
  74. data/spec/jira/resource/board_spec.rb +175 -0
  75. data/spec/jira/resource/createmeta_spec.rb +29 -32
  76. data/spec/jira/resource/field_spec.rb +42 -48
  77. data/spec/jira/resource/filter_spec.rb +40 -40
  78. data/spec/jira/resource/issue_spec.rb +87 -89
  79. data/spec/jira/resource/issuelink_spec.rb +1 -1
  80. data/spec/jira/resource/project_factory_spec.rb +2 -4
  81. data/spec/jira/resource/project_spec.rb +33 -33
  82. data/spec/jira/resource/sprint_spec.rb +78 -0
  83. data/spec/jira/resource/user_factory_spec.rb +6 -8
  84. data/spec/jira/resource/worklog_spec.rb +9 -11
  85. data/spec/spec_helper.rb +8 -9
  86. data/spec/support/clients_helper.rb +4 -4
  87. data/spec/support/shared_examples/integration.rb +60 -77
  88. metadata +59 -53
@@ -1,29 +1,26 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::Resource::Resolution do
4
-
5
4
  with_each_client do |site_url, client|
6
5
  let(:client) { client }
7
6
  let(:site_url) { site_url }
8
7
 
9
-
10
- let(:key) { "1" }
8
+ let(:key) { '1' }
11
9
 
12
10
  let(:expected_attributes) do
13
11
  {
14
- 'self' => "http://www.example.com/jira/rest/api/2/resolution/1",
12
+ 'self' => 'http://www.example.com/jira/rest/api/2/resolution/1',
15
13
  'id' => key,
16
14
  'name' => 'Fixed',
17
- 'description' => 'A fix for this issue is checked into the tree and tested.',
15
+ 'description' => 'A fix for this issue is checked into the tree and tested.',
18
16
  'iconUrl' => 'http://www.example.com/jira/images/icons/status_resolved.gif'
19
17
  }
20
18
  end
21
19
 
22
20
  let(:expected_collection_length) { 2 }
23
21
 
24
- it_should_behave_like "a resource"
25
- it_should_behave_like "a resource with a collection GET endpoint"
26
- it_should_behave_like "a resource with a singular GET endpoint"
27
-
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'
28
25
  end
29
- end
26
+ end
@@ -1,17 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::Resource::Status do
4
-
5
4
  with_each_client do |site_url, client|
6
5
  let(:client) { client }
7
6
  let(:site_url) { site_url }
8
7
 
9
-
10
- let(:key) { "1" }
8
+ let(:key) { '1' }
11
9
 
12
10
  let(:expected_attributes) do
13
11
  {
14
- 'self' => "http://localhost:2990/jira/rest/api/2/status/1",
12
+ 'self' => 'http://localhost:2990/jira/rest/api/2/status/1',
15
13
  'id' => key,
16
14
  'name' => 'Open'
17
15
  }
@@ -19,9 +17,8 @@ describe JIRA::Resource::Status do
19
17
 
20
18
  let(:expected_collection_length) { 5 }
21
19
 
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
-
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'
26
23
  end
27
24
  end
@@ -1,24 +1,23 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::Resource::Transition do
4
-
5
4
  with_each_client do |site_url, client|
6
5
  let(:client) { client }
7
6
  let(:site_url) { site_url }
8
7
 
9
8
  let(:key) { '10000' }
10
9
 
11
- let(:target) { JIRA::Resource::Transition.new(client, :attrs => {'id' => '99999'}, :issue_id => '10014') }
10
+ let(:target) { JIRA::Resource::Transition.new(client, attrs: { 'id' => '99999' }, issue_id: '10014') }
12
11
 
13
- let(:belongs_to) {
14
- JIRA::Resource::Issue.new(client, :attrs => {
15
- 'id' => '10002',
16
- 'self' => "#{site_url}/jira/rest/api/2/issue/10002",
17
- 'fields' => {
18
- 'comment' => {'comments' => []}
19
- }
20
- })
21
- }
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
22
21
 
23
22
  let(:expected_attributes) do
24
23
  {
@@ -27,26 +26,24 @@ describe JIRA::Resource::Transition do
27
26
  }
28
27
  end
29
28
 
30
- let(:attributes_for_post) {
29
+ let(:attributes_for_post) do
31
30
  {
32
31
  'transition' => {
33
32
  'id' => '42'
34
33
  }
35
34
  }
36
- }
35
+ end
37
36
 
38
- it_should_behave_like "a resource"
37
+ it_should_behave_like 'a resource'
39
38
 
40
- describe "POST endpoint" do
41
- it "saves a new resource" do
39
+ describe 'POST endpoint' do
40
+ it 'saves a new resource' do
42
41
  stub_request(:post, /#{described_class.collection_path(client, prefix)}$/)
43
- .with(:body => attributes_for_post.to_json)
44
- .to_return(:status => 200, :body => get_mock_from_path(:post))
42
+ .with(body: attributes_for_post.to_json)
43
+ .to_return(status: 200, body: get_mock_from_path(:post))
45
44
  subject = build_receiver.build
46
45
  expect(subject.save(attributes_for_post)).to be_truthy
47
46
  end
48
47
  end
49
-
50
48
  end
51
-
52
49
  end
@@ -1,25 +1,41 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::Resource::User do
4
-
5
-
6
4
  with_each_client do |site_url, client|
7
5
  let(:client) { client }
8
6
  let(:site_url) { site_url }
9
7
 
10
-
11
- let(:key) { "admin" }
8
+ let(:key) { 'admin' }
12
9
 
13
10
  let(:expected_attributes) do
14
11
  {
15
- 'self' => "http://localhost:2990/jira/rest/api/2/user?username=admin",
12
+ 'self' => 'http://localhost:2990/jira/rest/api/2/user?username=admin',
16
13
  'name' => key,
17
14
  'emailAddress' => 'admin@example.com'
18
15
  }
19
16
  end
20
17
 
21
- it_should_behave_like "a resource"
22
- it_should_behave_like "a resource with a singular GET endpoint"
23
-
18
+ it_should_behave_like 'a resource'
19
+ it_should_behave_like 'a resource with a singular GET endpoint'
20
+
21
+ describe '#all' do
22
+ let(:client) do
23
+ client = double(options: { rest_base_path: '/jira/rest/api/2' })
24
+ allow(client).to receive(:get).with('/rest/api/2/user/search?username=_&maxResults=1000').and_return(JIRA::Resource::UserFactory.new(client))
25
+ client
26
+ end
27
+
28
+ before do
29
+ allow(client).to receive(:get)
30
+ .with('/rest/api/2/user/search?username=_&maxResults=1000') { OpenStruct.new(body: '["User1"]') }
31
+ allow(client).to receive_message_chain(:User, :build).with('users') { [] }
32
+ end
33
+
34
+ it 'gets users with maxResults of 1000' do
35
+ expect(client).to receive(:get).with('/rest/api/2/user/search?username=_&maxResults=1000')
36
+ expect(client).to receive_message_chain(:User, :build).with('User1')
37
+ JIRA::Resource::User.all(client)
38
+ end
39
+ end
24
40
  end
25
41
  end
@@ -1,43 +1,39 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::Resource::Version do
4
-
5
-
6
4
  with_each_client do |site_url, client|
7
5
  let(:client) { client }
8
6
  let(:site_url) { site_url }
9
7
 
10
-
11
- let(:key) { "10000" }
8
+ let(:key) { '10000' }
12
9
 
13
10
  let(:expected_attributes) do
14
11
  {
15
- 'self' => "http://localhost:2990/jira/rest/api/2/version/10000",
12
+ 'self' => 'http://localhost:2990/jira/rest/api/2/version/10000',
16
13
  'id' => key,
17
- 'description' => "Initial version"
14
+ 'description' => 'Initial version'
18
15
  }
19
16
  end
20
17
 
21
- let(:attributes_for_post) {
22
- {"name" => "2.0", "project" => "SAMPLEPROJECT" }
23
- }
24
- let(:expected_attributes_from_post) {
25
- { "id" => "10001", "name" => "2.0" }
26
- }
27
-
28
- let(:attributes_for_put) {
29
- {"name" => "2.0.0" }
30
- }
31
- let(:expected_attributes_from_put) {
32
- { "id" => "10000", "name" => "2.0.0" }
33
- }
18
+ let(:attributes_for_post) do
19
+ { 'name' => '2.0', 'project' => 'SAMPLEPROJECT' }
20
+ end
21
+ let(:expected_attributes_from_post) do
22
+ { 'id' => '10001', 'name' => '2.0' }
23
+ end
34
24
 
35
- it_should_behave_like "a resource"
36
- it_should_behave_like "a resource with a singular GET endpoint"
37
- it_should_behave_like "a resource with a DELETE endpoint"
38
- it_should_behave_like "a resource with a POST endpoint"
39
- it_should_behave_like "a resource with a PUT endpoint"
40
- it_should_behave_like "a resource with a PUT endpoint that rejects invalid fields"
25
+ let(:attributes_for_put) do
26
+ { 'name' => '2.0.0' }
27
+ end
28
+ let(:expected_attributes_from_put) do
29
+ { 'id' => '10000', 'name' => '2.0.0' }
30
+ end
41
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'
42
38
  end
43
39
  end
@@ -1,59 +1,53 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::Resource::Watcher do
4
-
5
4
  with_each_client do |site_url, client|
6
5
  let(:client) { client }
7
6
  let(:site_url) { site_url }
8
7
 
8
+ let(:target) { JIRA::Resource::Watcher.new(client, attrs: { 'id' => '99999' }, issue_id: '10002') }
9
9
 
10
- let(:target) { JIRA::Resource::Watcher.new(client, :attrs => {'id' => '99999'}, :issue_id => '10002') }
11
-
12
- let(:belongs_to) {
13
- JIRA::Resource::Issue.new(client, :attrs => {
14
- 'id' => '10002',
15
- 'fields' => {
16
- 'comment' => {'comments' => []}
17
- }
18
- })
19
- }
10
+ let(:belongs_to) do
11
+ JIRA::Resource::Issue.new(client, attrs: {
12
+ 'id' => '10002',
13
+ 'fields' => {
14
+ 'comment' => { 'comments' => [] }
15
+ }
16
+ })
17
+ end
20
18
 
21
19
  let(:expected_attributes) do
22
20
  {
23
- "self" => "http://localhost:2990/jira/rest/api/2/issue/10002/watchers",
21
+ 'self' => 'http://localhost:2990/jira/rest/api/2/issue/10002/watchers',
24
22
  "isWatching": false,
25
23
  "watchCount": 1,
26
24
  "watchers": [
27
- {
28
- "self": "http://www.example.com/jira/rest/api/2/user?username=admin",
29
- "name": "admin",
30
- "displayName": "admin",
31
- "active": false
32
- }
25
+ {
26
+ "self": 'http://www.example.com/jira/rest/api/2/user?username=admin',
27
+ "name": 'admin',
28
+ "displayName": 'admin',
29
+ "active": false
30
+ }
33
31
  ]
34
32
  }
35
33
  end
36
34
 
37
- describe "watchers" do
38
- it "should returns all the watchers" do
39
-
40
- stub_request(:get,
41
- site_url + "/jira/rest/api/2/issue/10002").
42
- to_return(:status => 200, :body => get_mock_response('issue/10002.json'))
35
+ describe 'watchers' do
36
+ it 'should returns all the watchers' do
37
+ stub_request(:get,
38
+ site_url + '/jira/rest/api/2/issue/10002')
39
+ .to_return(status: 200, body: get_mock_response('issue/10002.json'))
43
40
 
44
- stub_request(:get,
45
- site_url + "/jira/rest/api/2/issue/10002/watchers").
46
- to_return(:status => 200, :body => get_mock_response('issue/10002/watchers.json'))
41
+ stub_request(:get,
42
+ site_url + '/jira/rest/api/2/issue/10002/watchers')
43
+ .to_return(status: 200, body: get_mock_response('issue/10002/watchers.json'))
47
44
 
48
- issue = client.Issue.find("10002")
49
- watchers = client.Watcher.all(options = {:issue => issue})
50
- expect(watchers.length).to eq(1)
45
+ issue = client.Issue.find('10002')
46
+ watchers = client.Watcher.all(options = { issue: issue })
47
+ expect(watchers.length).to eq(1)
51
48
  end
52
-
53
49
  end
54
50
 
55
- it_should_behave_like "a resource"
56
-
51
+ it_should_behave_like 'a resource'
57
52
  end
58
-
59
53
  end
@@ -1,34 +1,25 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::Resource::Webhook do
4
-
5
4
  with_each_client do |site_url, client|
6
5
  let(:client) { client }
7
6
  let(:site_url) { site_url }
8
7
 
9
-
10
- let(:key) { "2" }
8
+ let(:key) { '2' }
11
9
 
12
10
  let(:expected_attributes) do
13
- {"name"=>"from API", "url"=>"http://localhost:3000/webhooks/1", "excludeBody"=>false, "filters"=>{"issue-related-events-section"=>""}, "events"=>[], "enabled"=>true, "self"=>"http://localhost:2990/jira/rest/webhooks/1.0/webhook/2", "lastUpdatedUser"=>"admin", "lastUpdatedDisplayName"=>"admin", "lastUpdated"=>1453306520188}
11
+ { 'name' => 'from API', 'url' => 'http://localhost:3000/webhooks/1', 'excludeBody' => false, 'filters' => { 'issue-related-events-section' => '' }, 'events' => [], 'enabled' => true, 'self' => 'http://localhost:2990/jira/rest/webhooks/1.0/webhook/2', 'lastUpdatedUser' => 'admin', 'lastUpdatedDisplayName' => 'admin', 'lastUpdated' => 1_453_306_520_188 }
14
12
  end
15
13
 
16
14
  let(:expected_collection_length) { 1 }
17
15
 
18
- it_should_behave_like "a resource"
19
- it_should_behave_like "a resource with a collection GET endpoint"
20
- it_should_behave_like "a resource with a singular GET endpoint"
21
-
22
-
23
-
24
- it "returns a collection of components" do
25
-
26
- stub_request(:get, site_url + described_class.singular_path(client, key)).
27
- to_return(:status => 200, :body => get_mock_response('webhook/webhook.json'))
28
-
29
-
30
-
16
+ it_should_behave_like 'a resource'
17
+ it_should_behave_like 'a resource with a collection GET endpoint'
18
+ it_should_behave_like 'a resource with a singular GET endpoint'
31
19
 
20
+ it 'returns a collection of components' do
21
+ stub_request(:get, site_url + described_class.singular_path(client, key))
22
+ .to_return(status: 200, body: get_mock_response('webhook/webhook.json'))
32
23
  end
33
24
  end
34
25
  end
@@ -1,55 +1,51 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::Resource::Worklog do
4
-
5
-
6
4
  with_each_client do |site_url, client|
7
5
  let(:client) { client }
8
6
  let(:site_url) { site_url }
9
7
 
8
+ let(:key) { '10000' }
10
9
 
11
- let(:key) { "10000" }
12
-
13
- let(:target) { JIRA::Resource::Worklog.new(client, :attrs => {'id' => '99999'}, :issue_id => '54321') }
10
+ let(:target) { JIRA::Resource::Worklog.new(client, attrs: { 'id' => '99999' }, issue_id: '54321') }
14
11
 
15
12
  let(:expected_collection_length) { 3 }
16
13
 
17
- let(:belongs_to) {
18
- JIRA::Resource::Issue.new(client, :attrs => {
19
- 'id' => '10002', 'fields' => {
20
- 'comment' => {'comments' => []}
21
- }
22
- })
23
- }
14
+ let(:belongs_to) do
15
+ JIRA::Resource::Issue.new(client, attrs: {
16
+ 'id' => '10002', 'fields' => {
17
+ 'comment' => { 'comments' => [] }
18
+ }
19
+ })
20
+ end
24
21
 
25
22
  let(:expected_attributes) do
26
23
  {
27
- 'self' => "http://localhost:2990/jira/rest/api/2/issue/10002/worklog/10000",
24
+ 'self' => 'http://localhost:2990/jira/rest/api/2/issue/10002/worklog/10000',
28
25
  'id' => key,
29
- 'comment' => "Some epic work."
26
+ 'comment' => 'Some epic work.'
30
27
  }
31
28
  end
32
29
 
33
- let(:attributes_for_post) {
34
- {"timeSpent" => "2d"}
35
- }
36
- let(:expected_attributes_from_post) {
37
- { "id" => "10001", "timeSpent" => "2d"}
38
- }
39
-
40
- let(:attributes_for_put) {
41
- {"timeSpent" => "2d"}
42
- }
43
- let(:expected_attributes_from_put) {
44
- { "id" => "10001", "timeSpent" => "4d"}
45
- }
46
-
47
- it_should_behave_like "a resource"
48
- it_should_behave_like "a resource with a collection GET endpoint"
49
- it_should_behave_like "a resource with a singular GET endpoint"
50
- it_should_behave_like "a resource with a DELETE endpoint"
51
- it_should_behave_like "a resource with a POST endpoint"
52
- it_should_behave_like "a resource with a PUT endpoint"
30
+ let(:attributes_for_post) do
31
+ { 'timeSpent' => '2d' }
32
+ end
33
+ let(:expected_attributes_from_post) do
34
+ { 'id' => '10001', 'timeSpent' => '2d' }
35
+ end
36
+
37
+ let(:attributes_for_put) do
38
+ { 'timeSpent' => '2d' }
39
+ end
40
+ let(:expected_attributes_from_put) do
41
+ { 'id' => '10001', 'timeSpent' => '4d' }
42
+ end
53
43
 
44
+ it_should_behave_like 'a resource'
45
+ it_should_behave_like 'a resource with a collection GET endpoint'
46
+ it_should_behave_like 'a resource with a singular GET endpoint'
47
+ it_should_behave_like 'a resource with a DELETE endpoint'
48
+ it_should_behave_like 'a resource with a POST endpoint'
49
+ it_should_behave_like 'a resource with a PUT endpoint'
54
50
  end
55
51
  end