jira-ruby 2.2.0 → 3.0.0.beta1

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 (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 +121 -20
  12. data/Rakefile +4 -5
  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 +65 -46
  17. data/lib/jira/has_many_proxy.rb +4 -2
  18. data/lib/jira/http_client.rb +18 -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 +98 -26
  84. data/spec/jira/http_error_spec.rb +2 -2
  85. data/spec/jira/oauth_client_spec.rb +30 -8
  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 +18 -18
  94. data/spec/jira/resource/issue_spec.rb +44 -38
  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,113 +0,0 @@
1
- require 'rubygems'
2
- require 'pp'
3
- require 'jira-ruby'
4
-
5
- if ARGV.empty?
6
- # If not passed any command line arguments, prompt the
7
- # user for the username and password.
8
- puts 'Enter the username: '
9
- username = gets.strip
10
-
11
- puts 'Enter the password: '
12
- password = gets.strip
13
- elsif ARGV.length == 2
14
- username = ARGV[0]
15
- password = ARGV[1]
16
- else
17
- # Script must be passed 0 or 2 arguments
18
- raise "Usage: #{$PROGRAM_NAME} [ username password ]"
19
- end
20
-
21
- options = {
22
- username: username,
23
- password: password,
24
- site: 'http://localhost:8080/',
25
- context_path: '',
26
- auth_type: :basic,
27
- use_ssl: false
28
- }
29
-
30
- client = JIRA::Client.new(options)
31
-
32
- # Show all projects
33
- projects = client.Project.all
34
-
35
- projects.each do |project|
36
- puts "Project -> key: #{project.key}, name: #{project.name}"
37
- end
38
-
39
- # # Find a specific project by key
40
- # # ------------------------------
41
- # project = client.Project.find('SAMPLEPROJECT')
42
- # pp project
43
- # project.issues.each do |issue|
44
- # puts "#{issue.id} - #{issue.fields['summary']}"
45
- # end
46
- #
47
- # # List all Issues
48
- # # ---------------
49
- # client.Issue.all.each do |issue|
50
- # puts "#{issue.id} - #{issue.fields['summary']}"
51
- # end
52
- #
53
- # # List issues by JQL query
54
- # # ------------------------
55
- # client.Issue.jql('PROJECT = "SAMPLEPROJECT"', {fields: %w(summary status)}).each do |issue|
56
- # puts "#{issue.id} - #{issue.fields['summary']}"
57
- # end
58
- #
59
- # # Delete an issue
60
- # # ---------------
61
- # issue = client.Issue.find('SAMPLEPROJECT-2')
62
- # if issue.delete
63
- # puts "Delete of issue SAMPLEPROJECT-2 sucessful"
64
- # else
65
- # puts "Delete of issue SAMPLEPROJECT-2 failed"
66
- # end
67
- #
68
- # # Create an issue
69
- # # ---------------
70
- # issue = client.Issue.build
71
- # issue.save({"fields"=>{"summary"=>"blarg from in example.rb","project"=>{"id"=>"10001"},"issuetype"=>{"id"=>"3"}}})
72
- # issue.fetch
73
- # pp issue
74
- #
75
- # # Update an issue
76
- # # ---------------
77
- # issue = client.Issue.find("10002")
78
- # issue.save({"fields"=>{"summary"=>"EVEN MOOOOOOARRR NINJAAAA!"}})
79
- # pp issue
80
- #
81
- # # Find a user
82
- # # -----------
83
- # user = client.User.find('admin')
84
- # pp user
85
- #
86
- # # Get all issue types
87
- # # -------------------
88
- # issuetypes = client.Issuetype.all
89
- # pp issuetypes
90
- #
91
- # # Get a single issue type
92
- # # -----------------------
93
- # issuetype = client.Issuetype.find('5')
94
- # pp issuetype
95
- #
96
- # # Get all comments for an issue
97
- # # -----------------------------
98
- # issue.comments.each do |comment|
99
- # pp comment
100
- # end
101
- #
102
- # # Build and Save a comment
103
- # # ------------------------
104
- # comment = issue.comments.build
105
- # comment.save!(:body => "New comment from example script")
106
- #
107
- # # Delete a comment from the collection
108
- # # ------------------------------------
109
- # issue.comments.last.delete
110
- #
111
- # # Update an existing comment
112
- # # --------------------------
113
- # issue.comments.first.save({"body" => "an updated comment frome example.rb"})
@@ -1,8 +0,0 @@
1
- module JIRA
2
- module Resource
3
- class SprintReportFactory < JIRA::BaseFactory # :nodoc:
4
- end
5
-
6
- class SprintReport < JIRA::Base; end
7
- end
8
- end
data/lib/jira/tasks.rb DELETED
File without changes
@@ -1,59 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe JIRA::JwtClient::JwtUriBuilder do
4
- subject(:url_builder) do
5
- JIRA::JwtClient::JwtUriBuilder.new(url, http_method, shared_secret, site, issuer)
6
- end
7
-
8
- let(:url) { '/foo' }
9
- let(:http_method) { :get }
10
- let(:shared_secret) { 'shared_secret' }
11
- let(:site) { 'http://localhost:2990' }
12
- let(:issuer) { nil }
13
-
14
- describe '#build' do
15
- subject { url_builder.build }
16
-
17
- it 'includes the jwt param' do
18
- expect(subject).to include('?jwt=')
19
- end
20
-
21
- context 'when the url already contains params' do
22
- let(:url) { '/foo?expand=projects.issuetypes.fields' }
23
-
24
- it 'includes the jwt param' do
25
- expect(subject).to include('&jwt=')
26
- end
27
- end
28
-
29
- context 'with a complete url' do
30
- let(:url) { 'http://localhost:2990/rest/api/2/issue/createmeta' }
31
-
32
- it 'includes the jwt param' do
33
- expect(subject).to include('?jwt=')
34
- end
35
-
36
- it { is_expected.to start_with('/') }
37
-
38
- it 'contains only one ?' do
39
- expect(subject.count('?')).to eq(1)
40
- end
41
- end
42
-
43
- context 'with a complete url containing a param' do
44
- let(:url) do
45
- 'http://localhost:2990/rest/api/2/issue/createmeta?expand=projects.issuetypes.fields'
46
- end
47
-
48
- it 'includes the jwt param' do
49
- expect(subject).to include('&jwt=')
50
- end
51
-
52
- it { is_expected.to start_with('/') }
53
-
54
- it 'contains only one ?' do
55
- expect(subject.count('?')).to eq(1)
56
- end
57
- end
58
- end
59
- end