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,94 +1,93 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::Resource::Issue 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) { "10002" }
8
+ let(:key) { '10002' }
11
9
 
12
10
  let(:expected_attributes) do
13
11
  {
14
- 'self' => "http://localhost:2990/jira/rest/api/2/issue/10002",
15
- 'key' => "SAMPLEPROJECT-1",
16
- 'expand' => "renderedFields,names,schema,transitions,editmeta,changelog"
12
+ 'self' => 'http://localhost:2990/jira/rest/api/2/issue/10002',
13
+ 'key' => 'SAMPLEPROJECT-1',
14
+ 'expand' => 'renderedFields,names,schema,transitions,editmeta,changelog'
17
15
  }
18
16
  end
19
17
 
20
- let(:attributes_for_post) {
18
+ let(:attributes_for_post) do
21
19
  { 'foo' => 'bar' }
22
- }
23
- let(:expected_attributes_from_post) {
24
- { "id" => "10005", "key" => "SAMPLEPROJECT-4" }
25
- }
20
+ end
21
+ let(:expected_attributes_from_post) do
22
+ { 'id' => '10005', 'key' => 'SAMPLEPROJECT-4' }
23
+ end
26
24
 
27
- let(:attributes_for_put) {
25
+ let(:attributes_for_put) do
28
26
  { 'foo' => 'bar' }
29
- }
30
- let(:expected_attributes_from_put) {
27
+ end
28
+ let(:expected_attributes_from_put) do
31
29
  { 'foo' => 'bar' }
32
- }
30
+ end
33
31
  let(:expected_collection_length) { 11 }
34
32
 
35
- it_should_behave_like "a resource"
36
- it_should_behave_like "a resource with a singular GET endpoint"
37
- describe "GET all issues" do # JIRA::Resource::Issue.all uses the search endpoint
33
+ it_should_behave_like 'a resource'
34
+ it_should_behave_like 'a resource with a singular GET endpoint'
35
+ describe 'GET all issues' do # JIRA::Resource::Issue.all uses the search endpoint
38
36
  let(:client) { client }
39
37
  let(:site_url) { site_url }
40
38
 
41
- let(:expected_attributes) {
39
+ let(:expected_attributes) do
42
40
  {
43
- "id"=>"10014",
44
- "self"=>"http://localhost:2990/jira/rest/api/2/issue/10014",
45
- "key"=>"SAMPLEPROJECT-13"
41
+ 'id' => '10014',
42
+ 'self' => 'http://localhost:2990/jira/rest/api/2/issue/10014',
43
+ 'key' => 'SAMPLEPROJECT-13'
46
44
  }
47
- }
45
+ end
48
46
  before(:each) do
49
- stub_request(:get, site_url + "/jira/rest/api/2/search?expand=transitions.fields").
50
- to_return(:status => 200, :body => get_mock_response('issue.json'))
47
+ stub_request(:get, site_url + '/jira/rest/api/2/search?expand=transitions.fields&maxResults=1000&startAt=0')
48
+ .to_return(status: 200, body: get_mock_response('issue.json'))
49
+
50
+ stub_request(:get, site_url + '/jira/rest/api/2/search?expand=transitions.fields&maxResults=1000&startAt=11')
51
+ .to_return(status: 200, body: get_mock_response('empty_issues.json'))
51
52
  end
52
- it_should_behave_like "a resource with a collection GET endpoint"
53
+ it_should_behave_like 'a resource with a collection GET endpoint'
53
54
  end
54
- it_should_behave_like "a resource with a DELETE endpoint"
55
- it_should_behave_like "a resource with a POST endpoint"
56
- it_should_behave_like "a resource with a PUT endpoint"
57
- it_should_behave_like "a resource with a PUT endpoint that rejects invalid fields"
55
+ it_should_behave_like 'a resource with a DELETE endpoint'
56
+ it_should_behave_like 'a resource with a POST endpoint'
57
+ it_should_behave_like 'a resource with a PUT endpoint'
58
+ it_should_behave_like 'a resource with a PUT endpoint that rejects invalid fields'
58
59
 
59
- describe "errors" do
60
+ describe 'errors' do
60
61
  before(:each) do
61
62
  stub_request(:get,
62
- site_url + "/jira/rest/api/2/issue/10002").
63
- to_return(:status => 200, :body => get_mock_response('issue/10002.json'))
64
- stub_request(:put, site_url + "/jira/rest/api/2/issue/10002").
65
- with(:body => '{"missing":"fields and update"}').
66
- to_return(:status => 400, :body => get_mock_response('issue/10002.put.missing_field_update.json'))
63
+ site_url + '/jira/rest/api/2/issue/10002')
64
+ .to_return(status: 200, body: get_mock_response('issue/10002.json'))
65
+ stub_request(:put, site_url + '/jira/rest/api/2/issue/10002')
66
+ .with(body: '{"missing":"fields and update"}')
67
+ .to_return(status: 400, body: get_mock_response('issue/10002.put.missing_field_update.json'))
67
68
  end
68
69
 
69
- it "fails to save when fields and update are missing" do
70
+ it 'fails to save when fields and update are missing' do
70
71
  subject = client.Issue.build('id' => '10002')
71
72
  subject.fetch
72
73
  expect(subject.save('missing' => 'fields and update')).to be_falsey
73
74
  end
74
-
75
75
  end
76
76
 
77
- describe "GET jql issues" do # JIRA::Resource::Issue.jql uses the search endpoint
77
+ describe 'GET jql issues' do # JIRA::Resource::Issue.jql uses the search endpoint
78
78
  jql_query_string = "PROJECT = 'SAMPLEPROJECT'"
79
79
  let(:client) { client }
80
80
  let(:site_url) { site_url }
81
81
  let(:jql_query_string) { jql_query_string }
82
82
 
83
- let(:expected_attributes) {
83
+ let(:expected_attributes) do
84
84
  {
85
- "id"=>"10014",
86
- "self"=>"http://localhost:2990/jira/rest/api/2/issue/10014",
87
- "key"=>"SAMPLEPROJECT-13"
85
+ 'id' => '10014',
86
+ 'self' => 'http://localhost:2990/jira/rest/api/2/issue/10014',
87
+ 'key' => 'SAMPLEPROJECT-13'
88
88
  }
89
- }
90
- it_should_behave_like "a resource with JQL inputs and a collection GET endpoint"
89
+ end
90
+ it_should_behave_like 'a resource with JQL inputs and a collection GET endpoint'
91
91
  end
92
-
93
92
  end
94
93
  end
@@ -1,29 +1,26 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::Resource::Issuelinktype 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) { "10000" }
8
+ let(:key) { '10000' }
11
9
 
12
10
  let(:expected_attributes) do
13
11
  {
14
12
  'id' => key,
15
- "self"=>"http://localhost:2990/jira/rest/api/2/issueLinkType/10000",
16
- "name"=>"Blocks",
17
- "inward"=>"is blocked by",
18
- "outward"=>"blocks"
13
+ 'self' => 'http://localhost:2990/jira/rest/api/2/issueLinkType/10000',
14
+ 'name' => 'Blocks',
15
+ 'inward' => 'is blocked by',
16
+ 'outward' => 'blocks'
19
17
  }
20
18
  end
21
19
 
22
20
  let(:expected_collection_length) { 3 }
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
26
  end
@@ -1,16 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::Resource::Issuetype 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
- let(:key) { "5" }
8
+ let(:key) { '5' }
10
9
 
11
10
  let(:expected_attributes) do
12
11
  {
13
- 'self' => "http://localhost:2990/jira/rest/api/2/issuetype/5",
12
+ 'self' => 'http://localhost:2990/jira/rest/api/2/issuetype/5',
14
13
  'id' => key,
15
14
  'name' => 'Sub-task'
16
15
  }
@@ -18,9 +17,8 @@ describe JIRA::Resource::Issuetype do
18
17
 
19
18
  let(:expected_collection_length) { 5 }
20
19
 
21
- it_should_behave_like "a resource"
22
- it_should_behave_like "a resource with a collection GET endpoint"
23
- it_should_behave_like "a resource with a singular GET endpoint"
24
-
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'
25
23
  end
26
24
  end
@@ -1,17 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::Resource::Priority 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/priority/1",
12
+ 'self' => 'http://localhost:2990/jira/rest/api/2/priority/1',
15
13
  'id' => key,
16
14
  'name' => 'Blocker'
17
15
  }
@@ -19,9 +17,8 @@ describe JIRA::Resource::Priority 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,33 +1,30 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::Resource::Project 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) { "SAMPLEPROJECT" }
8
+ let(:key) { 'SAMPLEPROJECT' }
11
9
 
12
10
  let(:expected_attributes) do
13
11
  {
14
- 'self' => "http://localhost:2990/jira/rest/api/2/project/SAMPLEPROJECT",
12
+ 'self' => 'http://localhost:2990/jira/rest/api/2/project/SAMPLEPROJECT',
15
13
  'key' => key,
16
- 'name' => "Sample Project for Developing RoR RESTful API"
14
+ 'name' => 'Sample Project for Developing RoR RESTful API'
17
15
  }
18
16
  end
19
17
 
20
18
  let(:expected_collection_length) { 1 }
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"
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'
25
23
 
26
- describe "issues" do
27
-
28
- it "returns all the issues" do
29
- stub_request(:get, site_url + "/jira/rest/api/2/search?jql=project=\"SAMPLEPROJECT\"").
30
- to_return(:status => 200, :body => get_mock_response('project/SAMPLEPROJECT.issues.json'))
24
+ describe 'issues' do
25
+ it 'returns all the issues' do
26
+ stub_request(:get, site_url + '/jira/rest/api/2/search?jql=project="SAMPLEPROJECT"')
27
+ .to_return(status: 200, body: get_mock_response('project/SAMPLEPROJECT.issues.json'))
31
28
  subject = client.Project.build('key' => key)
32
29
  issues = subject.issues
33
30
  expect(issues.length).to eq(11)
@@ -35,22 +32,18 @@ describe JIRA::Resource::Project do
35
32
  expect(issue.class).to eq(JIRA::Resource::Issue)
36
33
  expect(issue.expanded?).to be_falsey
37
34
  end
38
-
39
35
  end
40
-
41
36
  end
42
37
 
43
- it "returns a collection of components" do
44
-
45
- stub_request(:get, site_url + described_class.singular_path(client, key)).
46
- to_return(:status => 200, :body => get_mock_response('project/SAMPLEPROJECT.json'))
38
+ it 'returns a collection of components' do
39
+ stub_request(:get, site_url + described_class.singular_path(client, key))
40
+ .to_return(status: 200, body: get_mock_response('project/SAMPLEPROJECT.json'))
47
41
 
48
42
  subject = client.Project.find(key)
49
43
  expect(subject.components.length).to eq(2)
50
44
  subject.components.each do |component|
51
45
  expect(component.class).to eq(JIRA::Resource::Component)
52
46
  end
53
-
54
47
  end
55
48
  end
56
49
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe JIRA::Resource::RapidView do
4
-
5
4
  with_each_client do |site_url, client|
6
5
  let(:client) { client }
7
6
  let(:site_url) { site_url }
@@ -10,14 +9,14 @@ describe JIRA::Resource::RapidView do
10
9
 
11
10
  let(:expected_collection_length) { 1 }
12
11
 
13
- let(:expected_attributes) {
12
+ let(:expected_attributes) do
14
13
  {
15
14
  'id' => 1,
16
15
  'name' => 'SAMPLEPROJECT',
17
16
  'canEdit' => true,
18
17
  'sprintSupportEnabled' => true
19
18
  }
20
- }
19
+ end
21
20
 
22
21
  it_should_behave_like 'a resource'
23
22
  # TODO@Anton: Add json file
@@ -28,8 +27,8 @@ describe JIRA::Resource::RapidView do
28
27
  let(:site_url) { site_url }
29
28
 
30
29
  before(:each) do
31
- stub_request(:get, site_url + '/jira/rest/greenhopper/1.0/rapidview').
32
- to_return(:status => 200, :body => get_mock_response('rapidview.json'))
30
+ stub_request(:get, site_url + '/jira/rest/greenhopper/1.0/rapidview')
31
+ .to_return(status: 200, body: get_mock_response('rapidview.json'))
33
32
  end
34
33
  it_should_behave_like 'a resource with a collection GET endpoint'
35
34
  end
@@ -41,16 +40,24 @@ describe JIRA::Resource::RapidView do
41
40
  site_url +
42
41
  '/jira/rest/greenhopper/1.0/xboard/plan/backlog/data?rapidViewId=1'
43
42
  ).to_return(
44
- :status => 200,
45
- :body => get_mock_response('rapidview/SAMPLEPROJECT.issues.json')
43
+ status: 200,
44
+ body: get_mock_response('rapidview/SAMPLEPROJECT.issues.json')
45
+ )
46
+
47
+ stub_request(
48
+ :get,
49
+ site_url + '/jira/rest/api/2/search?jql=id IN(10001, 10000)'
50
+ ).to_return(
51
+ status: 200,
52
+ body: get_mock_response('rapidview/SAMPLEPROJECT.issues.full.json')
46
53
  )
47
54
 
48
55
  stub_request(
49
56
  :get,
50
- site_url + '/jira/rest/api/2/search?jql=id IN(10000, 10001)'
57
+ site_url + '/jira/rest/api/2/search?jql=id IN(10000, 10001) AND sprint IS NOT EMPTY'
51
58
  ).to_return(
52
- :status => 200,
53
- :body => get_mock_response('rapidview/SAMPLEPROJECT.issues.full.json')
59
+ status: 200,
60
+ body: get_mock_response('rapidview/SAMPLEPROJECT.issues.full.json')
54
61
  )
55
62
 
56
63
  subject = client.RapidView.build('id' => 1)
@@ -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/users/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/users/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/users/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