jira-ruby 1.2.0 → 2.3.0

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 (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
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe JIRA::Resource::Watcher do
4
+ with_each_client do |site_url, client|
5
+ let(:client) { client }
6
+ let(:site_url) { site_url }
7
+
8
+ let(:target) { JIRA::Resource::Watcher.new(client, attrs: { 'id' => '99999' }, issue_id: '10002') }
9
+
10
+ let(:belongs_to) do
11
+ JIRA::Resource::Issue.new(client, attrs: {
12
+ 'id' => '10002',
13
+ 'fields' => {
14
+ 'comment' => { 'comments' => [] }
15
+ }
16
+ })
17
+ end
18
+
19
+ let(:expected_attributes) do
20
+ {
21
+ 'self' => 'http://localhost:2990/jira/rest/api/2/issue/10002/watchers',
22
+ "isWatching": false,
23
+ "watchCount": 1,
24
+ "watchers": [
25
+ {
26
+ "self": 'http://www.example.com/jira/rest/api/2/user?username=admin',
27
+ "name": 'admin',
28
+ "displayName": 'admin',
29
+ "active": false
30
+ }
31
+ ]
32
+ }
33
+ end
34
+
35
+ describe 'watchers' do
36
+ before(:each) do
37
+ stub_request(:get, site_url + '/jira/rest/api/2/issue/10002')
38
+ .to_return(status: 200, body: get_mock_response('issue/10002.json'))
39
+
40
+ stub_request(:get, site_url + '/jira/rest/api/2/issue/10002/watchers')
41
+ .to_return(status: 200, body: get_mock_response('issue/10002/watchers.json'))
42
+
43
+ stub_request(:post, site_url + '/jira/rest/api/2/issue/10002/watchers')
44
+ .to_return(status: 204, body: nil)
45
+ end
46
+
47
+ it 'should returns all the watchers' do
48
+ issue = client.Issue.find('10002')
49
+ watchers = client.Watcher.all(options = { issue: issue })
50
+ expect(watchers.length).to eq(1)
51
+ end
52
+
53
+ it 'should add a watcher' do
54
+ issue = client.Issue.find('10002')
55
+ watcher = JIRA::Resource::Watcher.new(client, issue: issue)
56
+ user_id = "tester"
57
+ watcher.save!(user_id)
58
+ end
59
+ end
60
+
61
+ end
62
+ 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
@@ -1,45 +1,44 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::BaseFactory do
4
+ class JIRA::Resource::FooFactory < JIRA::BaseFactory; end
5
+ class JIRA::Resource::Foo; end
4
6
 
5
- class JIRA::Resource::FooFactory < JIRA::BaseFactory ; end
6
- class JIRA::Resource::Foo ; end
7
-
8
- let(:client) { double() }
7
+ let(:client) { double }
9
8
  subject { JIRA::Resource::FooFactory.new(client) }
10
9
 
11
- it "initializes correctly" do
10
+ it 'initializes correctly' do
12
11
  expect(subject.class).to eq(JIRA::Resource::FooFactory)
13
12
  expect(subject.client).to eq(client)
14
13
  expect(subject.target_class).to eq(JIRA::Resource::Foo)
15
14
  end
16
15
 
17
- it "proxies all to the target class" do
16
+ it 'proxies all to the target class' do
18
17
  expect(JIRA::Resource::Foo).to receive(:all).with(client)
19
18
  subject.all
20
19
  end
21
20
 
22
- it "proxies find to the target class" do
21
+ it 'proxies find to the target class' do
23
22
  expect(JIRA::Resource::Foo).to receive(:find).with(client, 'FOO')
24
23
  subject.find('FOO')
25
24
  end
26
25
 
27
- it "returns the target class" do
26
+ it 'returns the target class' do
28
27
  expect(subject.target_class).to eq(JIRA::Resource::Foo)
29
28
  end
30
29
 
31
- it "proxies build to the target class" do
32
- attrs = double()
30
+ it 'proxies build to the target class' do
31
+ attrs = double
33
32
  expect(JIRA::Resource::Foo).to receive(:build).with(client, attrs)
34
33
  subject.build(attrs)
35
34
  end
36
35
 
37
- it "proxies collection path to the target class" do
36
+ it 'proxies collection path to the target class' do
38
37
  expect(JIRA::Resource::Foo).to receive(:collection_path).with(client)
39
38
  subject.collection_path
40
39
  end
41
40
 
42
- it "proxies singular path to the target class" do
41
+ it 'proxies singular path to the target class' do
43
42
  expect(JIRA::Resource::Foo).to receive(:singular_path).with(client, 'FOO')
44
43
  subject.singular_path('FOO')
45
44
  end