jira-ruby 2.3.0 → 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +20 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  4. data/.github/dependabot.yml +6 -0
  5. data/.github/workflows/CI.yml +28 -0
  6. data/.github/workflows/codeql.yml +100 -0
  7. data/.github/workflows/rubocop.yml +18 -0
  8. data/.rubocop.yml +188 -0
  9. data/Gemfile +11 -3
  10. data/Guardfile +2 -0
  11. data/README.md +94 -18
  12. data/Rakefile +3 -4
  13. data/jira-ruby.gemspec +11 -17
  14. data/lib/jira/base.rb +37 -28
  15. data/lib/jira/base_factory.rb +4 -1
  16. data/lib/jira/client.rb +64 -46
  17. data/lib/jira/has_many_proxy.rb +4 -2
  18. data/lib/jira/http_client.rb +17 -13
  19. data/lib/jira/http_error.rb +4 -0
  20. data/lib/jira/jwt_client.rb +18 -42
  21. data/lib/jira/oauth_client.rb +6 -3
  22. data/lib/jira/railtie.rb +2 -0
  23. data/lib/jira/request_client.rb +5 -1
  24. data/lib/jira/resource/agile.rb +7 -9
  25. data/lib/jira/resource/applinks.rb +5 -3
  26. data/lib/jira/resource/attachment.rb +43 -3
  27. data/lib/jira/resource/board.rb +5 -3
  28. data/lib/jira/resource/board_configuration.rb +2 -0
  29. data/lib/jira/resource/comment.rb +2 -0
  30. data/lib/jira/resource/component.rb +2 -0
  31. data/lib/jira/resource/createmeta.rb +3 -1
  32. data/lib/jira/resource/field.rb +9 -4
  33. data/lib/jira/resource/filter.rb +2 -0
  34. data/lib/jira/resource/issue.rb +35 -44
  35. data/lib/jira/resource/issue_picker_suggestions.rb +4 -1
  36. data/lib/jira/resource/issue_picker_suggestions_issue.rb +2 -0
  37. data/lib/jira/resource/issuelink.rb +2 -0
  38. data/lib/jira/resource/issuelinktype.rb +2 -0
  39. data/lib/jira/resource/issuetype.rb +2 -0
  40. data/lib/jira/resource/priority.rb +2 -0
  41. data/lib/jira/resource/project.rb +4 -2
  42. data/lib/jira/resource/rapidview.rb +5 -3
  43. data/lib/jira/resource/remotelink.rb +2 -0
  44. data/lib/jira/resource/resolution.rb +2 -0
  45. data/lib/jira/resource/serverinfo.rb +2 -0
  46. data/lib/jira/resource/sprint.rb +14 -23
  47. data/lib/jira/resource/status.rb +7 -1
  48. data/lib/jira/resource/status_category.rb +10 -0
  49. data/lib/jira/resource/suggested_issue.rb +2 -0
  50. data/lib/jira/resource/transition.rb +2 -0
  51. data/lib/jira/resource/user.rb +3 -1
  52. data/lib/jira/resource/version.rb +2 -0
  53. data/lib/jira/resource/watcher.rb +2 -1
  54. data/lib/jira/resource/webhook.rb +4 -2
  55. data/lib/jira/resource/worklog.rb +3 -2
  56. data/lib/jira/version.rb +3 -1
  57. data/lib/jira-ruby.rb +5 -3
  58. data/lib/tasks/generate.rake +4 -2
  59. data/spec/data/files/short.txt +1 -0
  60. data/spec/integration/attachment_spec.rb +3 -3
  61. data/spec/integration/comment_spec.rb +8 -8
  62. data/spec/integration/component_spec.rb +7 -7
  63. data/spec/integration/field_spec.rb +3 -3
  64. data/spec/integration/issue_spec.rb +20 -16
  65. data/spec/integration/issuelinktype_spec.rb +3 -3
  66. data/spec/integration/issuetype_spec.rb +3 -3
  67. data/spec/integration/priority_spec.rb +3 -3
  68. data/spec/integration/project_spec.rb +7 -7
  69. data/spec/integration/rapidview_spec.rb +9 -9
  70. data/spec/integration/resolution_spec.rb +3 -3
  71. data/spec/integration/status_category_spec.rb +20 -0
  72. data/spec/integration/status_spec.rb +4 -8
  73. data/spec/integration/transition_spec.rb +2 -2
  74. data/spec/integration/user_spec.rb +22 -8
  75. data/spec/integration/version_spec.rb +7 -7
  76. data/spec/integration/watcher_spec.rb +17 -18
  77. data/spec/integration/webhook.rb +5 -4
  78. data/spec/integration/worklog_spec.rb +8 -8
  79. data/spec/jira/base_factory_spec.rb +2 -1
  80. data/spec/jira/base_spec.rb +55 -41
  81. data/spec/jira/client_spec.rb +48 -34
  82. data/spec/jira/has_many_proxy_spec.rb +3 -3
  83. data/spec/jira/http_client_spec.rb +94 -27
  84. data/spec/jira/http_error_spec.rb +2 -2
  85. data/spec/jira/oauth_client_spec.rb +8 -6
  86. data/spec/jira/request_client_spec.rb +4 -4
  87. data/spec/jira/resource/agile_spec.rb +28 -28
  88. data/spec/jira/resource/attachment_spec.rb +142 -52
  89. data/spec/jira/resource/board_spec.rb +21 -20
  90. data/spec/jira/resource/createmeta_spec.rb +48 -48
  91. data/spec/jira/resource/field_spec.rb +30 -12
  92. data/spec/jira/resource/filter_spec.rb +4 -4
  93. data/spec/jira/resource/issue_picker_suggestions_spec.rb +17 -17
  94. data/spec/jira/resource/issue_spec.rb +43 -37
  95. data/spec/jira/resource/jira_picker_suggestions_issue_spec.rb +3 -3
  96. data/spec/jira/resource/project_factory_spec.rb +3 -2
  97. data/spec/jira/resource/project_spec.rb +16 -16
  98. data/spec/jira/resource/sprint_spec.rb +70 -3
  99. data/spec/jira/resource/status_spec.rb +21 -0
  100. data/spec/jira/resource/user_factory_spec.rb +4 -4
  101. data/spec/jira/resource/worklog_spec.rb +3 -3
  102. data/spec/mock_responses/sprint/1.json +13 -0
  103. data/spec/mock_responses/status/1.json +8 -1
  104. data/spec/mock_responses/status.json +40 -5
  105. data/spec/mock_responses/statuscategory/1.json +7 -0
  106. data/spec/mock_responses/statuscategory.json +30 -0
  107. data/spec/mock_responses/{user_username=admin.json → user_accountId=1234567890abcdef01234567.json} +2 -1
  108. data/spec/spec_helper.rb +1 -0
  109. data/spec/support/clients_helper.rb +3 -5
  110. data/spec/support/shared_examples/integration.rb +25 -28
  111. metadata +25 -257
  112. data/.travis.yml +0 -9
  113. data/example.rb +0 -232
  114. data/http-basic-example.rb +0 -113
  115. data/lib/jira/resource/sprint_report.rb +0 -8
  116. data/lib/jira/tasks.rb +0 -0
  117. data/spec/jira/jwt_uri_builder_spec.rb +0 -59
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module JIRA
2
4
  module Resource
3
5
  class WebhookFactory < JIRA::BaseFactory # :nodoc:
4
6
  end
5
7
 
6
8
  class Webhook < JIRA::Base
7
- REST_BASE_PATH = '/rest/webhooks/1.0'.freeze
9
+ REST_BASE_PATH = '/rest/webhooks/1.0'
8
10
 
9
11
  def self.endpoint_name
10
12
  'webhook'
@@ -22,7 +24,7 @@ module JIRA
22
24
  response = client.get(collection_path(client))
23
25
  json = parse_json(response.body)
24
26
  json.map do |attrs|
25
- new(client, { attrs: attrs }.merge(options))
27
+ new(client, { attrs: }.merge(options))
26
28
  end
27
29
  end
28
30
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module JIRA
2
4
  module Resource
3
5
  class WorklogFactory < JIRA::BaseFactory # :nodoc:
@@ -5,8 +7,7 @@ module JIRA
5
7
 
6
8
  class Worklog < JIRA::Base
7
9
  has_one :author, class: JIRA::Resource::User
8
- has_one :update_author, class: JIRA::Resource::User,
9
- attribute_key: 'updateAuthor'
10
+ has_one :update_author, class: JIRA::Resource::User, attribute_key: 'updateAuthor'
10
11
  belongs_to :issue
11
12
  nested_collections true
12
13
  end
data/lib/jira/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module JIRA
2
- VERSION = '2.3.0'.freeze
4
+ VERSION = '3.0.0.beta1'
3
5
  end
data/lib/jira-ruby.rb CHANGED
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  $LOAD_PATH << __dir__
2
4
 
3
5
  require 'active_support'
4
6
  require 'active_support/inflector'
5
7
  ActiveSupport::Inflector.inflections do |inflector|
6
- inflector.singular /status$/, 'status'
8
+ inflector.singular(/status$/, 'status')
7
9
  end
8
10
 
9
11
  require 'jira/base'
@@ -18,6 +20,7 @@ require 'jira/resource/component'
18
20
  require 'jira/resource/issuetype'
19
21
  require 'jira/resource/version'
20
22
  require 'jira/resource/status'
23
+ require 'jira/resource/status_category'
21
24
  require 'jira/resource/transition'
22
25
  require 'jira/resource/project'
23
26
  require 'jira/resource/priority'
@@ -31,12 +34,11 @@ require 'jira/resource/issue_picker_suggestions_issue'
31
34
  require 'jira/resource/issue_picker_suggestions'
32
35
  require 'jira/resource/remotelink'
33
36
  require 'jira/resource/sprint'
34
- require 'jira/resource/sprint_report'
37
+ require 'jira/resource/resolution'
35
38
  require 'jira/resource/issue'
36
39
  require 'jira/resource/filter'
37
40
  require 'jira/resource/field'
38
41
  require 'jira/resource/rapidview'
39
- require 'jira/resource/resolution'
40
42
  require 'jira/resource/serverinfo'
41
43
  require 'jira/resource/createmeta'
42
44
  require 'jira/resource/webhook'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'securerandom'
2
4
 
3
5
  namespace :jira do
@@ -10,8 +12,8 @@ namespace :jira do
10
12
  desc 'Run the system call to generate a RSA public certificate'
11
13
  task :generate_public_cert do
12
14
  puts "Executing 'openssl req -x509 -nodes -newkey rsa:1024 -sha1 -keyout rsakey.pem -out rsacert.pem'"
13
- system('openssl req -x509 -subj "/C=US/ST=New York/L=New York/O=SUMO Heavy Industries/CN=www.sumoheavy.com" -nodes -newkey rsa:1024 -sha1 -keyout rsakey.pem -out rsacert.pem')
14
- puts "Done. The RSA-SHA1 private keyfile is in the current directory: \'rsakey.pem\'."
15
+ system('openssl req -x509 -subj "/C=US/ST=New York/L=New York/O=SUMO Heavy Industries/CN=www.sumoheavy.com" -nodes -newkey rsa:1024 -sha1 -keyout rsakey.pem -out rsacert.pem') # rubocop:disable Layout/LineLength
16
+ puts "Done. The RSA-SHA1 private keyfile is in the current directory: 'rsakey.pem'."
15
17
  puts 'You will need to copy the following certificate into your application link configuration in Jira:'
16
18
  system('cat rsacert.pem')
17
19
  end
@@ -0,0 +1 @@
1
+ short text
@@ -7,7 +7,7 @@ describe JIRA::Resource::Attachment do
7
7
 
8
8
  let(:key) { '10000' }
9
9
 
10
- let(:target) { JIRA::Resource::Attachment.new(client, attrs: { 'id' => '99999' }, issue_id: '10002') }
10
+ let(:target) { described_class.new(client, attrs: { 'id' => '99999' }, issue_id: '10002') }
11
11
 
12
12
  let(:expected_attributes) do
13
13
  {
@@ -26,7 +26,7 @@ describe JIRA::Resource::Attachment do
26
26
  })
27
27
  end
28
28
 
29
- it_should_behave_like 'a resource with a singular GET endpoint'
30
- it_should_behave_like 'a resource with a DELETE endpoint'
29
+ it_behaves_like 'a resource with a singular GET endpoint'
30
+ it_behaves_like 'a resource with a DELETE endpoint'
31
31
  end
32
32
  end
@@ -7,7 +7,7 @@ describe JIRA::Resource::Comment do
7
7
 
8
8
  let(:key) { '10000' }
9
9
 
10
- let(:target) { JIRA::Resource::Comment.new(client, attrs: { 'id' => '99999' }, issue_id: '54321') }
10
+ let(:target) { described_class.new(client, attrs: { 'id' => '99999' }, issue_id: '54321') }
11
11
 
12
12
  let(:expected_collection_length) { 2 }
13
13
 
@@ -23,7 +23,7 @@ describe JIRA::Resource::Comment do
23
23
  let(:expected_attributes) do
24
24
  {
25
25
  'self' => 'http://localhost:2990/jira/rest/api/2/issue/10002/comment/10000',
26
- 'id' => key,
26
+ 'id' => key,
27
27
  'body' => 'This is a comment. Creative.'
28
28
  }
29
29
  end
@@ -42,11 +42,11 @@ describe JIRA::Resource::Comment do
42
42
  { 'id' => '10000', 'body' => 'new body' }
43
43
  end
44
44
 
45
- it_should_behave_like 'a resource'
46
- it_should_behave_like 'a resource with a collection GET endpoint'
47
- it_should_behave_like 'a resource with a singular GET endpoint'
48
- it_should_behave_like 'a resource with a DELETE endpoint'
49
- it_should_behave_like 'a resource with a POST endpoint'
50
- it_should_behave_like 'a resource with a PUT endpoint'
45
+ it_behaves_like 'a resource'
46
+ it_behaves_like 'a resource with a collection GET endpoint'
47
+ it_behaves_like 'a resource with a singular GET endpoint'
48
+ it_behaves_like 'a resource with a DELETE endpoint'
49
+ it_behaves_like 'a resource with a POST endpoint'
50
+ it_behaves_like 'a resource with a PUT endpoint'
51
51
  end
52
52
  end
@@ -10,7 +10,7 @@ describe JIRA::Resource::Component do
10
10
  let(:expected_attributes) do
11
11
  {
12
12
  'self' => 'http://localhost:2990/jira/rest/api/2/component/10000',
13
- 'id' => key,
13
+ 'id' => key,
14
14
  'name' => 'Cheesecake'
15
15
  }
16
16
  end
@@ -29,11 +29,11 @@ describe JIRA::Resource::Component do
29
29
  { 'id' => '10000', 'name' => 'Jammy' }
30
30
  end
31
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'
32
+ it_behaves_like 'a resource'
33
+ it_behaves_like 'a resource with a singular GET endpoint'
34
+ it_behaves_like 'a resource with a DELETE endpoint'
35
+ it_behaves_like 'a resource with a POST endpoint'
36
+ it_behaves_like 'a resource with a PUT endpoint'
37
+ it_behaves_like 'a resource with a PUT endpoint that rejects invalid fields'
38
38
  end
39
39
  end
@@ -25,8 +25,8 @@ describe JIRA::Resource::Field do
25
25
 
26
26
  let(:expected_collection_length) { 2 }
27
27
 
28
- it_should_behave_like 'a resource'
29
- it_should_behave_like 'a resource with a collection GET endpoint'
30
- it_should_behave_like 'a resource with a singular GET endpoint'
28
+ it_behaves_like 'a resource'
29
+ it_behaves_like 'a resource with a collection GET endpoint'
30
+ it_behaves_like 'a resource with a singular GET endpoint'
31
31
  end
32
32
  end
@@ -9,8 +9,8 @@ describe JIRA::Resource::Issue do
9
9
 
10
10
  let(:expected_attributes) do
11
11
  {
12
- 'self' => 'http://localhost:2990/jira/rest/api/2/issue/10002',
13
- 'key' => 'SAMPLEPROJECT-1',
12
+ 'self' => 'http://localhost:2990/jira/rest/api/2/issue/10002',
13
+ 'key' => 'SAMPLEPROJECT-1',
14
14
  'expand' => 'renderedFields,names,schema,transitions,editmeta,changelog'
15
15
  }
16
16
  end
@@ -30,8 +30,8 @@ describe JIRA::Resource::Issue do
30
30
  end
31
31
  let(:expected_collection_length) { 11 }
32
32
 
33
- it_should_behave_like 'a resource'
34
- it_should_behave_like 'a resource with a singular GET endpoint'
33
+ it_behaves_like 'a resource'
34
+ it_behaves_like 'a resource with a singular GET endpoint'
35
35
  describe 'GET all issues' do # JIRA::Resource::Issue.all uses the search endpoint
36
36
  let(:client) { client }
37
37
  let(:site_url) { site_url }
@@ -43,26 +43,29 @@ describe JIRA::Resource::Issue do
43
43
  'key' => 'SAMPLEPROJECT-13'
44
44
  }
45
45
  end
46
- before(:each) do
47
- stub_request(:get, site_url + '/jira/rest/api/2/search?expand=transitions.fields&maxResults=1000&startAt=0')
46
+
47
+ before do
48
+ stub_request(:get, "#{site_url}/jira/rest/api/2/search?expand=transitions.fields&maxResults=1000&startAt=0")
48
49
  .to_return(status: 200, body: get_mock_response('issue.json'))
49
50
 
50
- stub_request(:get, site_url + '/jira/rest/api/2/search?expand=transitions.fields&maxResults=1000&startAt=11')
51
+ stub_request(:get, "#{site_url}/jira/rest/api/2/search?expand=transitions.fields&maxResults=1000&startAt=11")
51
52
  .to_return(status: 200, body: get_mock_response('empty_issues.json'))
52
53
  end
53
- it_should_behave_like 'a resource with a collection GET endpoint'
54
+
55
+ it_behaves_like 'a resource with a collection GET endpoint'
54
56
  end
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'
57
+
58
+ it_behaves_like 'a resource with a DELETE endpoint'
59
+ it_behaves_like 'a resource with a POST endpoint'
60
+ it_behaves_like 'a resource with a PUT endpoint'
61
+ it_behaves_like 'a resource with a PUT endpoint that rejects invalid fields'
59
62
 
60
63
  describe 'errors' do
61
- before(:each) do
64
+ before do
62
65
  stub_request(:get,
63
- site_url + '/jira/rest/api/2/issue/10002')
66
+ "#{site_url}/jira/rest/api/2/issue/10002")
64
67
  .to_return(status: 200, body: get_mock_response('issue/10002.json'))
65
- stub_request(:put, site_url + '/jira/rest/api/2/issue/10002')
68
+ stub_request(:put, "#{site_url}/jira/rest/api/2/issue/10002")
66
69
  .with(body: '{"missing":"fields and update"}')
67
70
  .to_return(status: 400, body: get_mock_response('issue/10002.put.missing_field_update.json'))
68
71
  end
@@ -87,7 +90,8 @@ describe JIRA::Resource::Issue do
87
90
  'key' => 'SAMPLEPROJECT-13'
88
91
  }
89
92
  end
90
- it_should_behave_like 'a resource with JQL inputs and a collection GET endpoint'
93
+
94
+ it_behaves_like 'a resource with JQL inputs and a collection GET endpoint'
91
95
  end
92
96
  end
93
97
  end
@@ -19,8 +19,8 @@ describe JIRA::Resource::Issuelinktype do
19
19
 
20
20
  let(:expected_collection_length) { 3 }
21
21
 
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'
22
+ it_behaves_like 'a resource'
23
+ it_behaves_like 'a resource with a collection GET endpoint'
24
+ it_behaves_like 'a resource with a singular GET endpoint'
25
25
  end
26
26
  end
@@ -17,8 +17,8 @@ describe JIRA::Resource::Issuetype do
17
17
 
18
18
  let(:expected_collection_length) { 5 }
19
19
 
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'
20
+ it_behaves_like 'a resource'
21
+ it_behaves_like 'a resource with a collection GET endpoint'
22
+ it_behaves_like 'a resource with a singular GET endpoint'
23
23
  end
24
24
  end
@@ -17,8 +17,8 @@ describe JIRA::Resource::Priority do
17
17
 
18
18
  let(:expected_collection_length) { 5 }
19
19
 
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'
20
+ it_behaves_like 'a resource'
21
+ it_behaves_like 'a resource with a collection GET endpoint'
22
+ it_behaves_like 'a resource with a singular GET endpoint'
23
23
  end
24
24
  end
@@ -9,21 +9,21 @@ describe JIRA::Resource::Project do
9
9
 
10
10
  let(:expected_attributes) do
11
11
  {
12
- 'self' => 'http://localhost:2990/jira/rest/api/2/project/SAMPLEPROJECT',
13
- 'key' => key,
14
- 'name' => 'Sample Project for Developing RoR RESTful API'
12
+ 'self' => 'http://localhost:2990/jira/rest/api/2/project/SAMPLEPROJECT',
13
+ 'key' => key,
14
+ 'name' => 'Sample Project for Developing RoR RESTful API'
15
15
  }
16
16
  end
17
17
 
18
18
  let(:expected_collection_length) { 1 }
19
19
 
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'
20
+ it_behaves_like 'a resource'
21
+ it_behaves_like 'a resource with a collection GET endpoint'
22
+ it_behaves_like 'a resource with a singular GET endpoint'
23
23
 
24
24
  describe 'issues' do
25
25
  it 'returns all the issues' do
26
- stub_request(:get, site_url + '/jira/rest/api/2/search?jql=project="SAMPLEPROJECT"')
26
+ stub_request(:get, "#{site_url}/jira/rest/api/2/search?jql=project=\"SAMPLEPROJECT\"")
27
27
  .to_return(status: 200, body: get_mock_response('project/SAMPLEPROJECT.issues.json'))
28
28
  subject = client.Project.build('key' => key)
29
29
  issues = subject.issues
@@ -18,7 +18,7 @@ describe JIRA::Resource::RapidView do
18
18
  }
19
19
  end
20
20
 
21
- it_should_behave_like 'a resource'
21
+ it_behaves_like 'a resource'
22
22
  # TODO@Anton: Add json file
23
23
  # it_should_behave_like 'a resource with a singular GET endpoint'
24
24
 
@@ -26,19 +26,19 @@ describe JIRA::Resource::RapidView do
26
26
  let(:client) { client }
27
27
  let(:site_url) { site_url }
28
28
 
29
- before(:each) do
30
- stub_request(:get, site_url + '/jira/rest/greenhopper/1.0/rapidview')
29
+ before do
30
+ stub_request(:get, "#{site_url}/jira/rest/greenhopper/1.0/rapidview")
31
31
  .to_return(status: 200, body: get_mock_response('rapidview.json'))
32
32
  end
33
- it_should_behave_like 'a resource with a collection GET endpoint'
33
+
34
+ it_behaves_like 'a resource with a collection GET endpoint'
34
35
  end
35
36
 
36
37
  describe 'issues' do
37
- it 'should return all the issues' do
38
+ it 'returns all the issues' do
38
39
  stub_request(
39
40
  :get,
40
- site_url +
41
- '/jira/rest/greenhopper/1.0/xboard/plan/backlog/data?rapidViewId=1'
41
+ "#{site_url}/jira/rest/greenhopper/1.0/xboard/plan/backlog/data?rapidViewId=1"
42
42
  ).to_return(
43
43
  status: 200,
44
44
  body: get_mock_response('rapidview/SAMPLEPROJECT.issues.json')
@@ -46,7 +46,7 @@ describe JIRA::Resource::RapidView do
46
46
 
47
47
  stub_request(
48
48
  :get,
49
- site_url + '/jira/rest/api/2/search?jql=id IN(10001, 10000)'
49
+ "#{site_url}/jira/rest/api/2/search?jql=id IN(10001, 10000)"
50
50
  ).to_return(
51
51
  status: 200,
52
52
  body: get_mock_response('rapidview/SAMPLEPROJECT.issues.full.json')
@@ -54,7 +54,7 @@ describe JIRA::Resource::RapidView do
54
54
 
55
55
  stub_request(
56
56
  :get,
57
- site_url + '/jira/rest/api/2/search?jql=id IN(10000, 10001) AND sprint IS NOT EMPTY'
57
+ "#{site_url}/jira/rest/api/2/search?jql=id IN(10000, 10001) AND sprint IS NOT EMPTY"
58
58
  ).to_return(
59
59
  status: 200,
60
60
  body: get_mock_response('rapidview/SAMPLEPROJECT.issues.full.json')
@@ -19,8 +19,8 @@ describe JIRA::Resource::Resolution do
19
19
 
20
20
  let(:expected_collection_length) { 2 }
21
21
 
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'
22
+ it_behaves_like 'a resource'
23
+ it_behaves_like 'a resource with a collection GET endpoint'
24
+ it_behaves_like 'a resource with a singular GET endpoint'
25
25
  end
26
26
  end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe JIRA::Resource::StatusCategory do
4
+ with_each_client do |site_url, client|
5
+ let(:client) { client }
6
+ let(:site_url) { site_url }
7
+
8
+ let(:key) { 1 }
9
+
10
+ let(:expected_attributes) do
11
+ JSON.parse(File.read('spec/mock_responses/statuscategory/1.json'))
12
+ end
13
+
14
+ let(:expected_collection_length) { 4 }
15
+
16
+ it_behaves_like 'a resource'
17
+ it_behaves_like 'a resource with a collection GET endpoint'
18
+ it_behaves_like 'a resource with a singular GET endpoint'
19
+ end
20
+ end
@@ -8,17 +8,13 @@ describe JIRA::Resource::Status do
8
8
  let(:key) { '1' }
9
9
 
10
10
  let(:expected_attributes) do
11
- {
12
- 'self' => 'http://localhost:2990/jira/rest/api/2/status/1',
13
- 'id' => key,
14
- 'name' => 'Open'
15
- }
11
+ JSON.parse(File.read('spec/mock_responses/status/1.json'))
16
12
  end
17
13
 
18
14
  let(:expected_collection_length) { 5 }
19
15
 
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'
16
+ it_behaves_like 'a resource'
17
+ it_behaves_like 'a resource with a collection GET endpoint'
18
+ it_behaves_like 'a resource with a singular GET endpoint'
23
19
  end
24
20
  end
@@ -7,7 +7,7 @@ describe JIRA::Resource::Transition do
7
7
 
8
8
  let(:key) { '10000' }
9
9
 
10
- let(:target) { JIRA::Resource::Transition.new(client, attrs: { 'id' => '99999' }, issue_id: '10014') }
10
+ let(:target) { described_class.new(client, attrs: { 'id' => '99999' }, issue_id: '10014') }
11
11
 
12
12
  let(:belongs_to) do
13
13
  JIRA::Resource::Issue.new(client, attrs: {
@@ -34,7 +34,7 @@ describe JIRA::Resource::Transition do
34
34
  }
35
35
  end
36
36
 
37
- it_should_behave_like 'a resource'
37
+ it_behaves_like 'a resource'
38
38
 
39
39
  describe 'POST endpoint' do
40
40
  it 'saves a new resource' do
@@ -5,23 +5,37 @@ describe JIRA::Resource::User do
5
5
  let(:client) { client }
6
6
  let(:site_url) { site_url }
7
7
 
8
- let(:key) { 'admin' }
8
+ let(:key) { '1234567890abcdef01234567' }
9
9
 
10
10
  let(:expected_attributes) do
11
11
  {
12
- 'self' => 'http://localhost:2990/jira/rest/api/2/user?username=admin',
13
- 'name' => key,
14
- 'emailAddress' => 'admin@example.com'
12
+ 'id' => '1234567890abcdef01234567',
13
+ 'self' => 'http://localhost:2990/jira/rest/api/2/user?accountId=1234567890abcdef01234567',
14
+ 'name' => 'admin',
15
+ 'emailAddress' => 'admin@example.com',
16
+ 'avatarUrls' => {
17
+ '16x16' => 'http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122',
18
+ '48x48' => 'http://localhost:2990/jira/secure/useravatar?avatarId=10122'
19
+ },
20
+ 'displayName' => 'admin',
21
+ 'active' => true,
22
+ 'timeZone' => 'Pacific/Auckland',
23
+ 'groups' => {
24
+ 'size' => 3,
25
+ 'items' => []
26
+ },
27
+ 'expand' => 'groups'
15
28
  }
16
29
  end
17
30
 
18
- it_should_behave_like 'a resource'
19
- it_should_behave_like 'a resource with a singular GET endpoint'
31
+ it_behaves_like 'a resource'
32
+ it_behaves_like 'a resource with a singular GET endpoint'
20
33
 
21
34
  describe '#all' do
22
35
  let(:client) do
23
36
  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))
37
+ allow(client).to receive(:get).with('/rest/api/2/users/search?username=_&maxResults=1000')
38
+ .and_return(JIRA::Resource::UserFactory.new(client))
25
39
  client
26
40
  end
27
41
 
@@ -34,7 +48,7 @@ describe JIRA::Resource::User do
34
48
  it 'gets users with maxResults of 1000' do
35
49
  expect(client).to receive(:get).with('/rest/api/2/users/search?username=_&maxResults=1000')
36
50
  expect(client).to receive_message_chain(:User, :build).with('User1')
37
- JIRA::Resource::User.all(client)
51
+ described_class.all(client)
38
52
  end
39
53
  end
40
54
  end
@@ -10,7 +10,7 @@ describe JIRA::Resource::Version do
10
10
  let(:expected_attributes) do
11
11
  {
12
12
  'self' => 'http://localhost:2990/jira/rest/api/2/version/10000',
13
- 'id' => key,
13
+ 'id' => key,
14
14
  'description' => 'Initial version'
15
15
  }
16
16
  end
@@ -29,11 +29,11 @@ describe JIRA::Resource::Version do
29
29
  { 'id' => '10000', 'name' => '2.0.0' }
30
30
  end
31
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'
32
+ it_behaves_like 'a resource'
33
+ it_behaves_like 'a resource with a singular GET endpoint'
34
+ it_behaves_like 'a resource with a DELETE endpoint'
35
+ it_behaves_like 'a resource with a POST endpoint'
36
+ it_behaves_like 'a resource with a PUT endpoint'
37
+ it_behaves_like 'a resource with a PUT endpoint that rejects invalid fields'
38
38
  end
39
39
  end
@@ -5,7 +5,7 @@ describe JIRA::Resource::Watcher do
5
5
  let(:client) { client }
6
6
  let(:site_url) { site_url }
7
7
 
8
- let(:target) { JIRA::Resource::Watcher.new(client, attrs: { 'id' => '99999' }, issue_id: '10002') }
8
+ let(:target) { described_class.new(client, attrs: { 'id' => '99999' }, issue_id: '10002') }
9
9
 
10
10
  let(:belongs_to) do
11
11
  JIRA::Resource::Issue.new(client, attrs: {
@@ -19,44 +19,43 @@ describe JIRA::Resource::Watcher do
19
19
  let(:expected_attributes) do
20
20
  {
21
21
  'self' => 'http://localhost:2990/jira/rest/api/2/issue/10002/watchers',
22
- "isWatching": false,
23
- "watchCount": 1,
24
- "watchers": [
22
+ isWatching: false,
23
+ watchCount: 1,
24
+ watchers: [
25
25
  {
26
- "self": 'http://www.example.com/jira/rest/api/2/user?username=admin',
27
- "name": 'admin',
28
- "displayName": 'admin',
29
- "active": false
26
+ self: 'http://www.example.com/jira/rest/api/2/user?username=admin',
27
+ name: 'admin',
28
+ displayName: 'admin',
29
+ active: false
30
30
  }
31
31
  ]
32
32
  }
33
33
  end
34
34
 
35
35
  describe 'watchers' do
36
- before(:each) do
37
- stub_request(:get, site_url + '/jira/rest/api/2/issue/10002')
36
+ before do
37
+ stub_request(:get, "#{site_url}/jira/rest/api/2/issue/10002")
38
38
  .to_return(status: 200, body: get_mock_response('issue/10002.json'))
39
39
 
40
- stub_request(:get, site_url + '/jira/rest/api/2/issue/10002/watchers')
40
+ stub_request(:get, "#{site_url}/jira/rest/api/2/issue/10002/watchers")
41
41
  .to_return(status: 200, body: get_mock_response('issue/10002/watchers.json'))
42
42
 
43
- stub_request(:post, site_url + '/jira/rest/api/2/issue/10002/watchers')
43
+ stub_request(:post, "#{site_url}/jira/rest/api/2/issue/10002/watchers")
44
44
  .to_return(status: 204, body: nil)
45
45
  end
46
46
 
47
- it 'should returns all the watchers' do
47
+ it 'returnses all the watchers' do
48
48
  issue = client.Issue.find('10002')
49
- watchers = client.Watcher.all(options = { issue: issue })
49
+ watchers = client.Watcher.all(options = { issue: })
50
50
  expect(watchers.length).to eq(1)
51
51
  end
52
52
 
53
- it 'should add a watcher' do
53
+ it 'adds a watcher' do
54
54
  issue = client.Issue.find('10002')
55
- watcher = JIRA::Resource::Watcher.new(client, issue: issue)
56
- user_id = "tester"
55
+ watcher = described_class.new(client, issue:)
56
+ user_id = 'tester'
57
57
  watcher.save!(user_id)
58
58
  end
59
59
  end
60
-
61
60
  end
62
61
  end