jira-ruby 2.3.0 → 3.0.0.beta2
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.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +20 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/CI.yml +29 -0
- data/.github/workflows/codeql.yml +96 -0
- data/.github/workflows/rubocop.yml +18 -0
- data/.gitignore +3 -1
- data/.rubocop.yml +120 -0
- data/.yardopts +4 -0
- data/Gemfile +11 -3
- data/Guardfile +2 -0
- data/README.md +94 -18
- data/Rakefile +3 -4
- data/jira-ruby.gemspec +11 -17
- data/lib/jira/base.rb +37 -36
- data/lib/jira/base_factory.rb +4 -1
- data/lib/jira/client.rb +123 -50
- data/lib/jira/has_many_proxy.rb +32 -28
- data/lib/jira/http_client.rb +80 -13
- data/lib/jira/http_error.rb +4 -0
- data/lib/jira/jwt_client.rb +18 -42
- data/lib/jira/oauth_client.rb +68 -3
- data/lib/jira/railtie.rb +2 -0
- data/lib/jira/request_client.rb +31 -2
- data/lib/jira/resource/agile.rb +7 -9
- data/lib/jira/resource/applinks.rb +5 -3
- data/lib/jira/resource/attachment.rb +128 -3
- data/lib/jira/resource/board.rb +5 -3
- data/lib/jira/resource/board_configuration.rb +2 -0
- data/lib/jira/resource/comment.rb +2 -0
- data/lib/jira/resource/component.rb +2 -0
- data/lib/jira/resource/createmeta.rb +3 -1
- data/lib/jira/resource/field.rb +13 -12
- data/lib/jira/resource/filter.rb +2 -0
- data/lib/jira/resource/issue.rb +95 -44
- data/lib/jira/resource/issue_picker_suggestions.rb +4 -1
- data/lib/jira/resource/issue_picker_suggestions_issue.rb +2 -0
- data/lib/jira/resource/issuelink.rb +6 -3
- data/lib/jira/resource/issuelinktype.rb +2 -0
- data/lib/jira/resource/issuetype.rb +2 -0
- data/lib/jira/resource/priority.rb +2 -0
- data/lib/jira/resource/project.rb +4 -2
- data/lib/jira/resource/rapidview.rb +5 -3
- data/lib/jira/resource/remotelink.rb +2 -0
- data/lib/jira/resource/resolution.rb +2 -0
- data/lib/jira/resource/serverinfo.rb +2 -0
- data/lib/jira/resource/sprint.rb +14 -23
- data/lib/jira/resource/status.rb +7 -1
- data/lib/jira/resource/status_category.rb +10 -0
- data/lib/jira/resource/suggested_issue.rb +2 -0
- data/lib/jira/resource/transition.rb +2 -0
- data/lib/jira/resource/user.rb +3 -1
- data/lib/jira/resource/version.rb +2 -0
- data/lib/jira/resource/watcher.rb +3 -2
- data/lib/jira/resource/webhook.rb +9 -3
- data/lib/jira/resource/worklog.rb +3 -2
- data/lib/jira/version.rb +3 -1
- data/lib/jira-ruby.rb +5 -3
- data/lib/tasks/generate.rake +3 -1
- data/spec/data/files/short.txt +1 -0
- data/spec/integration/attachment_spec.rb +3 -3
- data/spec/integration/comment_spec.rb +8 -8
- data/spec/integration/component_spec.rb +7 -7
- data/spec/integration/field_spec.rb +3 -3
- data/spec/integration/issue_spec.rb +20 -16
- data/spec/integration/issuelinktype_spec.rb +3 -3
- data/spec/integration/issuetype_spec.rb +3 -3
- data/spec/integration/priority_spec.rb +3 -3
- data/spec/integration/project_spec.rb +8 -8
- data/spec/integration/rapidview_spec.rb +10 -10
- data/spec/integration/resolution_spec.rb +3 -3
- data/spec/integration/status_category_spec.rb +20 -0
- data/spec/integration/status_spec.rb +4 -8
- data/spec/integration/transition_spec.rb +2 -2
- data/spec/integration/user_spec.rb +34 -11
- data/spec/integration/version_spec.rb +7 -7
- data/spec/integration/watcher_spec.rb +21 -18
- data/spec/integration/webhook_spec.rb +33 -0
- data/spec/integration/worklog_spec.rb +8 -8
- data/spec/jira/base_factory_spec.rb +13 -3
- data/spec/jira/base_spec.rb +135 -98
- data/spec/jira/client_spec.rb +63 -47
- data/spec/jira/has_many_proxy_spec.rb +3 -3
- data/spec/jira/http_client_spec.rb +94 -27
- data/spec/jira/http_error_spec.rb +2 -2
- data/spec/jira/oauth_client_spec.rb +14 -8
- data/spec/jira/request_client_spec.rb +4 -4
- data/spec/jira/resource/agile_spec.rb +30 -30
- data/spec/jira/resource/attachment_spec.rb +170 -57
- data/spec/jira/resource/board_spec.rb +24 -23
- data/spec/jira/resource/createmeta_spec.rb +48 -48
- data/spec/jira/resource/field_spec.rb +44 -27
- data/spec/jira/resource/filter_spec.rb +4 -4
- data/spec/jira/resource/issue_picker_suggestions_spec.rb +17 -17
- data/spec/jira/resource/issue_spec.rb +49 -43
- data/spec/jira/resource/jira_picker_suggestions_issue_spec.rb +3 -3
- data/spec/jira/resource/project_factory_spec.rb +3 -2
- data/spec/jira/resource/project_spec.rb +14 -14
- data/spec/jira/resource/sprint_spec.rb +88 -9
- data/spec/jira/resource/status_spec.rb +21 -0
- data/spec/jira/resource/user_factory_spec.rb +5 -5
- data/spec/jira/resource/worklog_spec.rb +4 -4
- data/spec/mock_responses/sprint/1.json +13 -0
- data/spec/mock_responses/status/1.json +8 -1
- data/spec/mock_responses/status.json +40 -5
- data/spec/mock_responses/statuscategory/1.json +7 -0
- data/spec/mock_responses/statuscategory.json +30 -0
- data/spec/mock_responses/{user_username=admin.json → user_accountId=1234567890abcdef01234567.json} +2 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/support/clients_helper.rb +3 -5
- data/spec/support/mock_client.rb +9 -0
- data/spec/support/mock_response.rb +8 -0
- data/spec/support/shared_examples/integration.rb +25 -28
- metadata +27 -260
- data/.travis.yml +0 -9
- data/example.rb +0 -232
- data/http-basic-example.rb +0 -113
- data/lib/jira/resource/sprint_report.rb +0 -8
- data/lib/jira/tasks.rb +0 -0
- data/spec/integration/webhook.rb +0 -25
- data/spec/jira/jwt_uri_builder_spec.rb +0 -59
data/example.rb
DELETED
@@ -1,232 +0,0 @@
|
|
1
|
-
require 'pp'
|
2
|
-
require './lib/jira-ruby'
|
3
|
-
|
4
|
-
CONSUMER_KEY = 'test'
|
5
|
-
SITE = 'https://test.jira.com'
|
6
|
-
|
7
|
-
options = {
|
8
|
-
:private_key_file => "rsakey.pem",
|
9
|
-
:context_path => '',
|
10
|
-
:consumer_key => CONSUMER_KEY,
|
11
|
-
:site => SITE
|
12
|
-
}
|
13
|
-
|
14
|
-
client = JIRA::Client.new(options)
|
15
|
-
|
16
|
-
if ARGV.length == 0
|
17
|
-
# If not passed any command line arguments, open a browser and prompt the
|
18
|
-
# user for the OAuth verifier.
|
19
|
-
request_token = client.request_token
|
20
|
-
puts "Opening #{request_token.authorize_url}"
|
21
|
-
system "open #{request_token.authorize_url}"
|
22
|
-
|
23
|
-
puts "Enter the oauth_verifier: "
|
24
|
-
oauth_verifier = gets.strip
|
25
|
-
|
26
|
-
access_token = client.init_access_token(:oauth_verifier => oauth_verifier)
|
27
|
-
puts "Access token: #{access_token.token} secret: #{access_token.secret}"
|
28
|
-
elsif ARGV.length == 2
|
29
|
-
# Otherwise assume the arguments are a previous access token and secret.
|
30
|
-
access_token = client.set_access_token(ARGV[0], ARGV[1])
|
31
|
-
else
|
32
|
-
# Script must be passed 0 or 2 arguments
|
33
|
-
raise "Usage: #{$0} [ token secret ]"
|
34
|
-
end
|
35
|
-
|
36
|
-
# Show all projects
|
37
|
-
projects = client.Project.all
|
38
|
-
|
39
|
-
projects.each do |project|
|
40
|
-
puts "Project -> key: #{project.key}, name: #{project.name}"
|
41
|
-
end
|
42
|
-
issue = client.Issue.find('SAMPLEPROJECT-1')
|
43
|
-
pp issue
|
44
|
-
|
45
|
-
# # Handling fields by name, rather than by id
|
46
|
-
# # ------------------------------------------
|
47
|
-
# Cache the Field list from the server
|
48
|
-
client.Field.map_fields
|
49
|
-
# This allows use of friendlier names for custom fields
|
50
|
-
# Say that 'Special Field' is customfield_12345
|
51
|
-
# It becomes mapped to Special_Field which is usable as a method call
|
52
|
-
#
|
53
|
-
# Say that there is a second 'Special Field' is customfield_54321
|
54
|
-
# Names are deduplicated so the second 'Special Field' becomes Special_Field_54321
|
55
|
-
#
|
56
|
-
# Names are massaged to get rid of special characters, and spaces
|
57
|
-
# So 'Special & @ Field' becomes Special_____Field - not perfect, but usable
|
58
|
-
old_way = issue.customfield_12345
|
59
|
-
new_way = issue.Special_Field
|
60
|
-
(old_way == new_way) && puts 'much easier'
|
61
|
-
#
|
62
|
-
# You can also specify fields to be returned in the response
|
63
|
-
# This is especially useful in regards to shortening JQL query response times if performance becomes an issue
|
64
|
-
client.Issue.jql(a_normal_jql_search, fields:[:description, :summary, :Special_field, :created])
|
65
|
-
# Or you could always do it the old way - if you can remember the custom field numbers...
|
66
|
-
client.Issue.jql(a_normal_jql_search, fields:[:description, :summary, :customfield_1234, :created])
|
67
|
-
# You can also specify the maximum number of results to be returned in the response, i.e. 500
|
68
|
-
client.Issue.jql(a_normal_jql_search, max_results: 500)
|
69
|
-
|
70
|
-
# # Find a specific project by key
|
71
|
-
# # ------------------------------
|
72
|
-
# project = client.Project.find('SAMPLEPROJECT')
|
73
|
-
# pp project
|
74
|
-
# project.issues.each do |issue|
|
75
|
-
# puts "#{issue.id} - #{issue.fields['summary']}"
|
76
|
-
# end
|
77
|
-
#
|
78
|
-
# # List all Issues
|
79
|
-
# # ---------------
|
80
|
-
# client.Issue.all.each do |issue|
|
81
|
-
# puts "#{issue.id} - #{issue.fields['summary']}"
|
82
|
-
# end
|
83
|
-
#
|
84
|
-
# # List issues by JQL query
|
85
|
-
# # ------------------------
|
86
|
-
# client.Issue.jql('PROJECT = "SAMPLEPROJECT"', [comments, summary]).each do |issue|
|
87
|
-
# puts "#{issue.id} - #{issue.fields['summary']}"
|
88
|
-
# end
|
89
|
-
#
|
90
|
-
# # Delete an issue
|
91
|
-
# # ---------------
|
92
|
-
# issue = client.Issue.find('SAMPLEPROJECT-2')
|
93
|
-
# if issue.delete
|
94
|
-
# puts "Delete of issue SAMPLEPROJECT-2 sucessful"
|
95
|
-
# else
|
96
|
-
# puts "Delete of issue SAMPLEPROJECT-2 failed"
|
97
|
-
# end
|
98
|
-
#
|
99
|
-
# # Create an issue
|
100
|
-
# # ---------------
|
101
|
-
# issue = client.Issue.build
|
102
|
-
# labels = ['label1', 'label2']
|
103
|
-
# issue.save({
|
104
|
-
# "fields" => {
|
105
|
-
# "summary" => "blarg from in example.rb",
|
106
|
-
# "project" => {"key" => "SAMPLEPROJECT"},
|
107
|
-
# "issuetype" => {"id" => "3"},
|
108
|
-
# "labels" => labels,
|
109
|
-
# "priority" => {"id" => "1"}
|
110
|
-
# }
|
111
|
-
# })
|
112
|
-
# issue.fetch
|
113
|
-
# pp issue
|
114
|
-
#
|
115
|
-
# # Update an issue
|
116
|
-
# # ---------------
|
117
|
-
# issue = client.Issue.find("10002")
|
118
|
-
# issue.save({"fields"=>{"summary"=>"EVEN MOOOOOOARRR NINJAAAA!"}})
|
119
|
-
# pp issue
|
120
|
-
#
|
121
|
-
# # Transition an issue
|
122
|
-
# # -------------------
|
123
|
-
# issue_transition = issue.transitions.build
|
124
|
-
# issue_transition.save!('transition' => {'id' => transition_id})
|
125
|
-
#
|
126
|
-
# # Change assignee
|
127
|
-
# # -------------------
|
128
|
-
# issue.save({'fields' => {'assignee' => {'name' => person_name}}})
|
129
|
-
#
|
130
|
-
# # Find a user
|
131
|
-
# # -----------
|
132
|
-
# user = client.User.find('admin')
|
133
|
-
# pp user
|
134
|
-
#
|
135
|
-
# # Get all issue watchers
|
136
|
-
# # ----------------------
|
137
|
-
# issue = client.Issue.find("10002")
|
138
|
-
# watchers = issue.watchers.all
|
139
|
-
# watchers = client.Watcher.all(:issue => issue)
|
140
|
-
# # Get all issue types
|
141
|
-
# # -------------------
|
142
|
-
# issuetypes = client.Issuetype.all
|
143
|
-
# pp issuetypes
|
144
|
-
#
|
145
|
-
# # Get a single issue type
|
146
|
-
# # -----------------------
|
147
|
-
# issuetype = client.Issuetype.find('5')
|
148
|
-
# pp issuetype
|
149
|
-
#
|
150
|
-
# # Get all comments for an issue
|
151
|
-
# # -----------------------------
|
152
|
-
# issue.comments.each do |comment|
|
153
|
-
# pp comment
|
154
|
-
# end
|
155
|
-
#
|
156
|
-
# # Build and Save a comment
|
157
|
-
# # ------------------------
|
158
|
-
# comment = issue.comments.build
|
159
|
-
# comment.save!(:body => "New comment from example script")
|
160
|
-
#
|
161
|
-
# # Delete a comment from the collection
|
162
|
-
# # ------------------------------------
|
163
|
-
# issue.comments.last.delete
|
164
|
-
#
|
165
|
-
# # Update an existing comment
|
166
|
-
# # --------------------------
|
167
|
-
# issue.comments.first.save({"body" => "an updated comment frome example.rb"})
|
168
|
-
|
169
|
-
|
170
|
-
# # Add attachment to Issue
|
171
|
-
# # ------------------------
|
172
|
-
# issue = client.Issue.find('PROJ-1')
|
173
|
-
# attachment = issue.attachments.build
|
174
|
-
# attachment.save('file': '/path/to/file')
|
175
|
-
#
|
176
|
-
|
177
|
-
# List all available link types
|
178
|
-
# ------------------------------
|
179
|
-
pp client.Issuelinktype.all
|
180
|
-
|
181
|
-
# List issue's links
|
182
|
-
# -------------------------
|
183
|
-
issue = client.Issue.find("10002")
|
184
|
-
pp issue.issuelinks
|
185
|
-
|
186
|
-
# Link two issues (on the same Jira instance)
|
187
|
-
# --------------------------------------------
|
188
|
-
link = client.Issuelink.build
|
189
|
-
link.save(
|
190
|
-
{
|
191
|
-
:type => {:name => 'Relates'},
|
192
|
-
:inwardIssue => {:key => 'AL-1'},
|
193
|
-
:outwardIssue => {:key => 'AL-2'}
|
194
|
-
}
|
195
|
-
)
|
196
|
-
|
197
|
-
# List issue's remote links
|
198
|
-
# -------------------------
|
199
|
-
pp issue.remotelink.all
|
200
|
-
|
201
|
-
# Link two remote issues (on the different Jira instance)
|
202
|
-
# In order to add remote links, you have to add
|
203
|
-
# Application Links between two Jira instances first.
|
204
|
-
# More information:
|
205
|
-
# https://developer.atlassian.com/jiradev/jira-platform/guides/other/guide-jira-remote-issue-links/fields-in-remote-issue-links
|
206
|
-
# http://stackoverflow.com/questions/29850252/jira-api-issuelink-connect-two-different-instances
|
207
|
-
# -------------------------------------------------------
|
208
|
-
client_1 = JIRA::Client.new(options)
|
209
|
-
client_2 = JIRA::Client.new(options)
|
210
|
-
|
211
|
-
# you have to search for your app id here, instead of getting the first
|
212
|
-
client_2_app_link = client_2.ApplicationLink.manifest
|
213
|
-
issue_1 = client_1.Issue.find('BB-2')
|
214
|
-
issue_2 = client_2.Issue.find('AA-1')
|
215
|
-
|
216
|
-
remote_link = issue_2.remotelink.build
|
217
|
-
|
218
|
-
remote_link.save(
|
219
|
-
{
|
220
|
-
:globalId => "appId=#{client_2_app_link.id}&issueId=#{issue_1.id}",
|
221
|
-
:application => {
|
222
|
-
:type => 'com.atlassian.jira',
|
223
|
-
:name => client_2_app_link['name']
|
224
|
-
},
|
225
|
-
:relationship => 'relates to',
|
226
|
-
|
227
|
-
:object => {
|
228
|
-
:url => client_1.options[:site] + client_1.options[:context_path] + "/browse/#{issue_1.key}",
|
229
|
-
:title => issue_1.key,
|
230
|
-
}
|
231
|
-
}
|
232
|
-
)
|
data/http-basic-example.rb
DELETED
@@ -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"})
|
data/lib/jira/tasks.rb
DELETED
File without changes
|
data/spec/integration/webhook.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe JIRA::Resource::Webhook do
|
4
|
-
with_each_client do |site_url, client|
|
5
|
-
let(:client) { client }
|
6
|
-
let(:site_url) { site_url }
|
7
|
-
|
8
|
-
let(:key) { '2' }
|
9
|
-
|
10
|
-
let(:expected_attributes) do
|
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 }
|
12
|
-
end
|
13
|
-
|
14
|
-
let(:expected_collection_length) { 1 }
|
15
|
-
|
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'
|
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'))
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -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
|