jira-ruby 1.1.3 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +3 -0
- data/.travis.yml +5 -3
- data/Gemfile +7 -1
- data/Guardfile +1 -1
- data/README.md +452 -0
- data/Rakefile +6 -7
- data/example.rb +38 -6
- data/http-basic-example.rb +14 -13
- data/jira-ruby.gemspec +13 -13
- data/lib/jira/base.rb +58 -53
- data/lib/jira/base_factory.rb +3 -6
- data/lib/jira/client.rb +127 -30
- data/lib/jira/has_many_proxy.rb +0 -1
- data/lib/jira/http_client.rb +54 -16
- data/lib/jira/http_error.rb +3 -5
- data/lib/jira/jwt_client.rb +67 -0
- data/lib/jira/oauth_client.rb +47 -17
- data/lib/jira/request_client.rb +16 -5
- data/lib/jira/resource/agile.rb +34 -9
- data/lib/jira/resource/applinks.rb +5 -8
- data/lib/jira/resource/attachment.rb +41 -3
- data/lib/jira/resource/board.rb +91 -0
- data/lib/jira/resource/board_configuration.rb +9 -0
- data/lib/jira/resource/comment.rb +0 -2
- data/lib/jira/resource/component.rb +1 -3
- data/lib/jira/resource/createmeta.rb +14 -22
- data/lib/jira/resource/field.rb +22 -22
- data/lib/jira/resource/filter.rb +2 -2
- data/lib/jira/resource/issue.rb +69 -38
- data/lib/jira/resource/issue_picker_suggestions.rb +24 -0
- data/lib/jira/resource/issue_picker_suggestions_issue.rb +10 -0
- data/lib/jira/resource/issuelink.rb +3 -5
- data/lib/jira/resource/issuelinktype.rb +0 -1
- data/lib/jira/resource/issuetype.rb +1 -3
- data/lib/jira/resource/priority.rb +1 -3
- data/lib/jira/resource/project.rb +8 -8
- data/lib/jira/resource/rapidview.rb +28 -7
- data/lib/jira/resource/remotelink.rb +1 -4
- data/lib/jira/resource/resolution.rb +2 -4
- data/lib/jira/resource/serverinfo.rb +1 -2
- data/lib/jira/resource/sprint.rb +86 -17
- data/lib/jira/resource/sprint_report.rb +8 -0
- data/lib/jira/resource/status.rb +1 -3
- data/lib/jira/resource/suggested_issue.rb +9 -0
- data/lib/jira/resource/transition.rb +2 -6
- data/lib/jira/resource/user.rb +12 -2
- data/lib/jira/resource/version.rb +1 -3
- data/lib/jira/resource/watcher.rb +35 -0
- data/lib/jira/resource/webhook.rb +3 -6
- data/lib/jira/resource/worklog.rb +3 -5
- data/lib/jira/version.rb +1 -1
- data/lib/jira-ruby.rb +12 -2
- data/lib/tasks/generate.rake +4 -4
- data/spec/integration/attachment_spec.rb +17 -8
- data/spec/integration/comment_spec.rb +31 -34
- data/spec/integration/component_spec.rb +21 -24
- data/spec/integration/field_spec.rb +15 -18
- data/spec/integration/issue_spec.rb +45 -46
- data/spec/integration/issuelinktype_spec.rb +8 -11
- data/spec/integration/issuetype_spec.rb +5 -7
- data/spec/integration/priority_spec.rb +5 -8
- data/spec/integration/project_spec.rb +13 -20
- data/spec/integration/rapidview_spec.rb +17 -10
- data/spec/integration/resolution_spec.rb +7 -10
- data/spec/integration/status_spec.rb +5 -8
- data/spec/integration/transition_spec.rb +17 -20
- data/spec/integration/user_spec.rb +24 -8
- data/spec/integration/version_spec.rb +21 -25
- data/spec/integration/watcher_spec.rb +62 -0
- data/spec/integration/webhook.rb +8 -17
- data/spec/integration/worklog_spec.rb +30 -34
- data/spec/jira/base_factory_spec.rb +11 -12
- data/spec/jira/base_spec.rb +216 -229
- data/spec/jira/client_spec.rb +227 -159
- data/spec/jira/has_many_proxy_spec.rb +11 -12
- data/spec/jira/http_client_spec.rb +254 -31
- data/spec/jira/http_error_spec.rb +7 -9
- data/spec/jira/jwt_uri_builder_spec.rb +59 -0
- data/spec/jira/oauth_client_spec.rb +110 -39
- data/spec/jira/request_client_spec.rb +36 -9
- data/spec/jira/resource/agile_spec.rb +135 -0
- data/spec/jira/resource/attachment_spec.rb +127 -9
- data/spec/jira/resource/board_spec.rb +224 -0
- data/spec/jira/resource/createmeta_spec.rb +39 -34
- data/spec/jira/resource/field_spec.rb +42 -48
- data/spec/jira/resource/filter_spec.rb +40 -40
- data/spec/jira/resource/issue_picker_suggestions_spec.rb +79 -0
- data/spec/jira/resource/issue_spec.rb +88 -85
- data/spec/jira/resource/issuelink_spec.rb +1 -1
- data/spec/jira/resource/jira_picker_suggestions_issue_spec.rb +18 -0
- data/spec/jira/resource/project_factory_spec.rb +2 -4
- data/spec/jira/resource/project_spec.rb +86 -33
- data/spec/jira/resource/sprint_spec.rb +90 -0
- data/spec/jira/resource/user_factory_spec.rb +6 -8
- data/spec/jira/resource/worklog_spec.rb +9 -11
- data/spec/mock_responses/board/1.json +33 -0
- data/spec/mock_responses/board/1_issues.json +62 -0
- data/spec/mock_responses/empty_issues.json +8 -0
- data/spec/mock_responses/issue/10002/watchers.json +13 -0
- data/spec/mock_responses/issue.json +1 -1
- data/spec/mock_responses/sprint/1_issues.json +125 -0
- data/spec/spec_helper.rb +8 -9
- data/spec/support/clients_helper.rb +4 -4
- data/spec/support/shared_examples/integration.rb +60 -77
- metadata +115 -54
- data/README.rdoc +0 -329
- /data/spec/mock_responses/{attachment → issue/10002/attachments}/10000.json +0 -0
data/lib/jira/resource/sprint.rb
CHANGED
@@ -1,36 +1,105 @@
|
|
1
|
-
require 'cgi'
|
2
|
-
|
3
1
|
module JIRA
|
4
2
|
module Resource
|
5
|
-
|
6
3
|
class SprintFactory < JIRA::BaseFactory # :nodoc:
|
7
4
|
end
|
8
5
|
|
9
6
|
class Sprint < JIRA::Base
|
7
|
+
def self.find(client, key)
|
8
|
+
response = client.get(agile_path(client, key))
|
9
|
+
json = parse_json(response.body)
|
10
|
+
client.Sprint.build(json)
|
11
|
+
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
# get all issues of sprint
|
14
|
+
def issues(options = {})
|
15
|
+
jql = 'sprint = ' + id.to_s
|
16
|
+
jql += " and updated >= '#{options[:updated]}'" if options[:updated]
|
17
|
+
Issue.jql(client, jql)
|
14
18
|
end
|
15
19
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
parse_json(response.body)
|
20
|
+
def add_issue(issue)
|
21
|
+
request_body = { issues: [issue.id] }.to_json
|
22
|
+
response = client.post("#{agile_path}/issue", request_body)
|
23
|
+
true
|
21
24
|
end
|
22
25
|
|
23
|
-
|
26
|
+
def sprint_report
|
27
|
+
get_sprint_details_attribute('sprint_report')
|
28
|
+
end
|
24
29
|
|
25
|
-
def
|
26
|
-
|
30
|
+
def start_date
|
31
|
+
get_sprint_details_attribute('start_date')
|
27
32
|
end
|
28
33
|
|
29
|
-
def
|
30
|
-
|
34
|
+
def end_date
|
35
|
+
get_sprint_details_attribute('end_date')
|
31
36
|
end
|
32
37
|
|
33
|
-
|
38
|
+
def complete_date
|
39
|
+
get_sprint_details_attribute('complete_date')
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_sprint_details_attribute(attribute_name)
|
43
|
+
attribute = instance_variable_get("@#{attribute_name}")
|
44
|
+
return attribute if attribute
|
45
|
+
get_sprint_details
|
46
|
+
instance_variable_get("@#{attribute_name}")
|
47
|
+
end
|
48
|
+
|
49
|
+
def get_sprint_details
|
50
|
+
search_url =
|
51
|
+
"#{client.options[:site]}#{client.options[:client_path]}/rest/greenhopper/1.0/rapid/charts/sprintreport?rapidViewId=#{rapidview_id}&sprintId=#{id}"
|
52
|
+
begin
|
53
|
+
response = client.get(search_url)
|
54
|
+
rescue StandardError
|
55
|
+
return nil
|
56
|
+
end
|
57
|
+
json = self.class.parse_json(response.body)
|
58
|
+
|
59
|
+
@start_date = Date.parse(json['sprint']['startDate']) unless json['sprint']['startDate'] == 'None'
|
60
|
+
@end_date = Date.parse(json['sprint']['endDate']) unless json['sprint']['endDate'] == 'None'
|
61
|
+
@completed_date = Date.parse(json['sprint']['completeDate']) unless json['sprint']['completeDate'] == 'None'
|
62
|
+
@sprint_report = client.SprintReport.build(json['contents'])
|
63
|
+
end
|
64
|
+
|
65
|
+
def rapidview_id
|
66
|
+
return @attrs['rapidview_id'] if @attrs['rapidview_id']
|
67
|
+
search_url = client.options[:site] + '/secure/GHGoToBoard.jspa?sprintId=' + id.to_s
|
68
|
+
begin
|
69
|
+
response = client.get(search_url)
|
70
|
+
rescue JIRA::HTTPError => error
|
71
|
+
return unless error.response.instance_of? Net::HTTPFound
|
72
|
+
rapid_view_match = /rapidView=(\d+)&/.match(error.response['location'])
|
73
|
+
@attrs['rapidview_id'] = rapid_view_match[1] unless rapid_view_match.nil?
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def save(attrs = {}, _path = nil)
|
78
|
+
attrs = @attrs if attrs.empty?
|
79
|
+
super(attrs, agile_path)
|
80
|
+
end
|
81
|
+
|
82
|
+
def save!(attrs = {}, _path = nil)
|
83
|
+
attrs = @attrs if attrs.empty?
|
84
|
+
super(attrs, agile_path)
|
85
|
+
end
|
86
|
+
|
87
|
+
# WORK IN PROGRESS
|
88
|
+
def complete
|
89
|
+
complete_url = "#{client.options[:site]}/rest/greenhopper/1.0/sprint/#{id}/complete"
|
90
|
+
response = client.put(complete_url)
|
91
|
+
self.class.parse_json(response.body)
|
92
|
+
end
|
34
93
|
|
94
|
+
private
|
95
|
+
|
96
|
+
def agile_path
|
97
|
+
self.class.agile_path(client, id)
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.agile_path(client, key)
|
101
|
+
"#{client.options[:context_path]}/rest/agile/1.0/sprint/#{key}"
|
102
|
+
end
|
103
|
+
end
|
35
104
|
end
|
36
105
|
end
|
data/lib/jira/resource/status.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
module JIRA
|
2
2
|
module Resource
|
3
|
-
|
4
3
|
class TransitionFactory < JIRA::BaseFactory # :nodoc:
|
5
4
|
end
|
6
5
|
|
7
6
|
class Transition < JIRA::Base
|
8
|
-
has_one :to, :
|
7
|
+
has_one :to, class: JIRA::Resource::Status
|
9
8
|
belongs_to :issue
|
10
9
|
|
11
10
|
nested_collections true
|
@@ -16,9 +15,7 @@ module JIRA
|
|
16
15
|
|
17
16
|
def self.all(client, options = {})
|
18
17
|
issue = options[:issue]
|
19
|
-
unless issue
|
20
|
-
raise ArgumentError.new("parent issue is required")
|
21
|
-
end
|
18
|
+
raise ArgumentError, 'parent issue is required' unless issue
|
22
19
|
|
23
20
|
path = "#{issue.self}/#{endpoint_name}?expand=transitions.fields"
|
24
21
|
response = client.get(path)
|
@@ -28,6 +25,5 @@ module JIRA
|
|
28
25
|
end
|
29
26
|
end
|
30
27
|
end
|
31
|
-
|
32
28
|
end
|
33
29
|
end
|
data/lib/jira/resource/user.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module JIRA
|
2
2
|
module Resource
|
3
|
-
|
4
3
|
class UserFactory < JIRA::BaseFactory # :nodoc:
|
5
4
|
def myself
|
6
5
|
instance = build
|
@@ -11,10 +10,21 @@ module JIRA
|
|
11
10
|
end
|
12
11
|
|
13
12
|
class User < JIRA::Base
|
13
|
+
MAX_RESULTS = 1000
|
14
|
+
|
14
15
|
def self.singular_path(client, key, prefix = '/')
|
15
16
|
collection_path(client, prefix) + '?username=' + key
|
16
17
|
end
|
17
|
-
end
|
18
18
|
|
19
|
+
# Cannot retrieve more than 1,000 users through the api, please see: https://jira.atlassian.com/browse/JRASERVER-65089
|
20
|
+
def self.all(client)
|
21
|
+
response = client.get("/rest/api/2/users/search?username=_&maxResults=#{MAX_RESULTS}")
|
22
|
+
all_users = JSON.parse(response.body)
|
23
|
+
|
24
|
+
all_users.flatten.uniq.map do |user|
|
25
|
+
client.User.build(user)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
19
29
|
end
|
20
30
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module JIRA
|
2
|
+
module Resource
|
3
|
+
class WatcherFactory < JIRA::BaseFactory # :nodoc:
|
4
|
+
end
|
5
|
+
|
6
|
+
class Watcher < JIRA::Base
|
7
|
+
belongs_to :issue
|
8
|
+
|
9
|
+
nested_collections true
|
10
|
+
|
11
|
+
def self.endpoint_name
|
12
|
+
'watchers'
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.all(client, options = {})
|
16
|
+
issue = options[:issue]
|
17
|
+
raise ArgumentError, 'parent issue is required' unless issue
|
18
|
+
|
19
|
+
path = "#{issue.self}/#{endpoint_name}"
|
20
|
+
response = client.get(path)
|
21
|
+
json = parse_json(response.body)
|
22
|
+
json['watchers'].map do |watcher|
|
23
|
+
issue.watchers.build(watcher)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def save!(user_id, path = nil)
|
28
|
+
path ||= new_record? ? url : patched_url
|
29
|
+
response = client.post(path, user_id.to_json)
|
30
|
+
true
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,12 +1,10 @@
|
|
1
1
|
module JIRA
|
2
2
|
module Resource
|
3
|
-
|
4
3
|
class WebhookFactory < JIRA::BaseFactory # :nodoc:
|
5
4
|
end
|
6
5
|
|
7
6
|
class Webhook < JIRA::Base
|
8
|
-
|
9
|
-
REST_BASE_PATH = '/rest/webhooks/1.0'
|
7
|
+
REST_BASE_PATH = '/rest/webhooks/1.0'.freeze
|
10
8
|
|
11
9
|
def self.endpoint_name
|
12
10
|
'webhook'
|
@@ -17,14 +15,14 @@ module JIRA
|
|
17
15
|
end
|
18
16
|
|
19
17
|
def self.collection_path(client, prefix = '/')
|
20
|
-
|
18
|
+
full_url(client) + prefix + endpoint_name
|
21
19
|
end
|
22
20
|
|
23
21
|
def self.all(client, options = {})
|
24
22
|
response = client.get(collection_path(client))
|
25
23
|
json = parse_json(response.body)
|
26
24
|
json.map do |attrs|
|
27
|
-
|
25
|
+
new(client, { attrs: attrs }.merge(options))
|
28
26
|
end
|
29
27
|
end
|
30
28
|
|
@@ -34,7 +32,6 @@ module JIRA
|
|
34
32
|
# def self.delete(options={})
|
35
33
|
|
36
34
|
# end
|
37
|
-
|
38
35
|
end
|
39
36
|
end
|
40
37
|
end
|
@@ -1,16 +1,14 @@
|
|
1
1
|
module JIRA
|
2
2
|
module Resource
|
3
|
-
|
4
3
|
class WorklogFactory < JIRA::BaseFactory # :nodoc:
|
5
4
|
end
|
6
5
|
|
7
6
|
class Worklog < JIRA::Base
|
8
|
-
has_one :author, :
|
9
|
-
has_one :update_author, :
|
10
|
-
:
|
7
|
+
has_one :author, class: JIRA::Resource::User
|
8
|
+
has_one :update_author, class: JIRA::Resource::User,
|
9
|
+
attribute_key: 'updateAuthor'
|
11
10
|
belongs_to :issue
|
12
11
|
nested_collections true
|
13
12
|
end
|
14
|
-
|
15
13
|
end
|
16
14
|
end
|
data/lib/jira/version.rb
CHANGED
data/lib/jira-ruby.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
$LOAD_PATH << __dir__
|
2
2
|
|
3
|
+
require 'active_support'
|
3
4
|
require 'active_support/inflector'
|
4
5
|
ActiveSupport::Inflector.inflections do |inflector|
|
5
6
|
inflector.singular /status$/, 'status'
|
@@ -11,6 +12,7 @@ require 'jira/has_many_proxy'
|
|
11
12
|
require 'jira/http_error'
|
12
13
|
|
13
14
|
require 'jira/resource/user'
|
15
|
+
require 'jira/resource/watcher'
|
14
16
|
require 'jira/resource/attachment'
|
15
17
|
require 'jira/resource/component'
|
16
18
|
require 'jira/resource/issuetype'
|
@@ -24,7 +26,12 @@ require 'jira/resource/worklog'
|
|
24
26
|
require 'jira/resource/applinks'
|
25
27
|
require 'jira/resource/issuelinktype'
|
26
28
|
require 'jira/resource/issuelink'
|
29
|
+
require 'jira/resource/suggested_issue'
|
30
|
+
require 'jira/resource/issue_picker_suggestions_issue'
|
31
|
+
require 'jira/resource/issue_picker_suggestions'
|
27
32
|
require 'jira/resource/remotelink'
|
33
|
+
require 'jira/resource/sprint'
|
34
|
+
require 'jira/resource/sprint_report'
|
28
35
|
require 'jira/resource/issue'
|
29
36
|
require 'jira/resource/filter'
|
30
37
|
require 'jira/resource/field'
|
@@ -34,10 +41,13 @@ require 'jira/resource/serverinfo'
|
|
34
41
|
require 'jira/resource/createmeta'
|
35
42
|
require 'jira/resource/webhook'
|
36
43
|
require 'jira/resource/agile'
|
37
|
-
require 'jira/resource/
|
44
|
+
require 'jira/resource/board'
|
45
|
+
require 'jira/resource/board_configuration'
|
46
|
+
|
38
47
|
require 'jira/request_client'
|
39
48
|
require 'jira/oauth_client'
|
40
49
|
require 'jira/http_client'
|
50
|
+
require 'jira/jwt_client'
|
41
51
|
require 'jira/client'
|
42
52
|
|
43
53
|
require 'jira/railtie' if defined?(Rails)
|
data/lib/tasks/generate.rake
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
require 'securerandom'
|
2
2
|
|
3
3
|
namespace :jira do
|
4
|
-
desc
|
4
|
+
desc 'Generate a consumer key for your application'
|
5
5
|
task :generate_consumer_key do
|
6
6
|
key = SecureRandom.hex(16)
|
7
7
|
puts "You can use this as your consumer key: #{key}"
|
8
8
|
end
|
9
9
|
|
10
|
-
desc
|
10
|
+
desc 'Run the system call to generate a RSA public certificate'
|
11
11
|
task :generate_public_cert do
|
12
12
|
puts "Executing 'openssl req -x509 -nodes -newkey rsa:1024 -sha1 -keyout rsakey.pem -out rsacert.pem'"
|
13
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
14
|
puts "Done. The RSA-SHA1 private keyfile is in the current directory: \'rsakey.pem\'."
|
15
|
-
puts
|
16
|
-
system(
|
15
|
+
puts 'You will need to copy the following certificate into your application link configuration in Jira:'
|
16
|
+
system('cat rsacert.pem')
|
17
17
|
end
|
18
18
|
end
|
@@ -1,23 +1,32 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe JIRA::Resource::Attachment 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) {
|
8
|
+
let(:key) { '10000' }
|
9
|
+
|
10
|
+
let(:target) { JIRA::Resource::Attachment.new(client, attrs: { 'id' => '99999' }, issue_id: '10002') }
|
10
11
|
|
11
12
|
let(:expected_attributes) do
|
12
13
|
{
|
13
|
-
'self' =>
|
14
|
-
'size' =>
|
15
|
-
'filename' =>
|
14
|
+
'self' => 'http://localhost:2990/jira/rest/api/2/attachment/10000',
|
15
|
+
'size' => 15_360,
|
16
|
+
'filename' => 'ballmer.png'
|
16
17
|
}
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
let(:belongs_to) do
|
21
|
+
JIRA::Resource::Issue.new(client, attrs: {
|
22
|
+
'id' => '10002',
|
23
|
+
'fields' => {
|
24
|
+
'attachment' => { 'attachments' => [] }
|
25
|
+
}
|
26
|
+
})
|
27
|
+
end
|
28
|
+
|
29
|
+
it_should_behave_like 'a resource with a singular GET endpoint'
|
30
|
+
it_should_behave_like 'a resource with a DELETE endpoint'
|
22
31
|
end
|
23
32
|
end
|
@@ -1,55 +1,52 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe JIRA::Resource::Comment 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) {
|
8
|
+
let(:key) { '10000' }
|
10
9
|
|
11
|
-
let(:target) { JIRA::Resource::Comment.new(client, :
|
10
|
+
let(:target) { JIRA::Resource::Comment.new(client, attrs: { 'id' => '99999' }, issue_id: '54321') }
|
12
11
|
|
13
12
|
let(:expected_collection_length) { 2 }
|
14
13
|
|
15
|
-
let(:belongs_to)
|
16
|
-
JIRA::Resource::Issue.new(client, :
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
14
|
+
let(:belongs_to) do
|
15
|
+
JIRA::Resource::Issue.new(client, attrs: {
|
16
|
+
'id' => '10002',
|
17
|
+
'fields' => {
|
18
|
+
'comment' => { 'comments' => [] }
|
19
|
+
}
|
20
|
+
})
|
21
|
+
end
|
23
22
|
|
24
23
|
let(:expected_attributes) do
|
25
24
|
{
|
26
|
-
'self' =>
|
25
|
+
'self' => 'http://localhost:2990/jira/rest/api/2/issue/10002/comment/10000',
|
27
26
|
'id' => key,
|
28
|
-
'body' =>
|
27
|
+
'body' => 'This is a comment. Creative.'
|
29
28
|
}
|
30
29
|
end
|
31
30
|
|
32
|
-
let(:attributes_for_post)
|
33
|
-
{
|
34
|
-
|
35
|
-
let(:expected_attributes_from_post)
|
36
|
-
{
|
37
|
-
|
38
|
-
|
39
|
-
let(:attributes_for_put)
|
40
|
-
{
|
41
|
-
|
42
|
-
let(:expected_attributes_from_put)
|
43
|
-
{
|
44
|
-
|
45
|
-
|
46
|
-
it_should_behave_like "a resource"
|
47
|
-
it_should_behave_like "a resource with a collection GET endpoint"
|
48
|
-
it_should_behave_like "a resource with a singular GET endpoint"
|
49
|
-
it_should_behave_like "a resource with a DELETE endpoint"
|
50
|
-
it_should_behave_like "a resource with a POST endpoint"
|
51
|
-
it_should_behave_like "a resource with a PUT endpoint"
|
31
|
+
let(:attributes_for_post) do
|
32
|
+
{ 'body' => 'new comment' }
|
33
|
+
end
|
34
|
+
let(:expected_attributes_from_post) do
|
35
|
+
{ 'id' => '10001', 'body' => 'new comment' }
|
36
|
+
end
|
37
|
+
|
38
|
+
let(:attributes_for_put) do
|
39
|
+
{ 'body' => 'new body' }
|
40
|
+
end
|
41
|
+
let(:expected_attributes_from_put) do
|
42
|
+
{ 'id' => '10000', 'body' => 'new body' }
|
43
|
+
end
|
52
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'
|
53
51
|
end
|
54
|
-
|
55
52
|
end
|
@@ -1,42 +1,39 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe JIRA::Resource::Component 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
|
-
let(:key) {
|
8
|
+
let(:key) { '10000' }
|
11
9
|
|
12
10
|
let(:expected_attributes) do
|
13
11
|
{
|
14
|
-
'self' =>
|
12
|
+
'self' => 'http://localhost:2990/jira/rest/api/2/component/10000',
|
15
13
|
'id' => key,
|
16
|
-
'name' =>
|
14
|
+
'name' => 'Cheesecake'
|
17
15
|
}
|
18
16
|
end
|
19
17
|
|
20
|
-
let(:attributes_for_post)
|
21
|
-
{
|
22
|
-
|
23
|
-
let(:expected_attributes_from_post)
|
24
|
-
{
|
25
|
-
|
26
|
-
|
27
|
-
let(:attributes_for_put) {
|
28
|
-
{"name" => "Jammy", "project" => "SAMPLEPROJECT" }
|
29
|
-
}
|
30
|
-
let(:expected_attributes_from_put) {
|
31
|
-
{ "id" => "10000", "name" => "Jammy" }
|
32
|
-
}
|
18
|
+
let(:attributes_for_post) do
|
19
|
+
{ 'name' => 'Test component', 'project' => 'SAMPLEPROJECT' }
|
20
|
+
end
|
21
|
+
let(:expected_attributes_from_post) do
|
22
|
+
{ 'id' => '10001', 'name' => 'Test component' }
|
23
|
+
end
|
33
24
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
25
|
+
let(:attributes_for_put) do
|
26
|
+
{ 'name' => 'Jammy', 'project' => 'SAMPLEPROJECT' }
|
27
|
+
end
|
28
|
+
let(:expected_attributes_from_put) do
|
29
|
+
{ 'id' => '10000', 'name' => 'Jammy' }
|
30
|
+
end
|
40
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'
|
41
38
|
end
|
42
39
|
end
|
@@ -1,35 +1,32 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe JIRA::Resource::Field 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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
12
|
+
'id' => key,
|
13
|
+
'name' => 'Description',
|
14
|
+
'custom' => false,
|
15
|
+
'orderable' => true,
|
16
|
+
'navigable' => true,
|
17
|
+
'searchable' => true,
|
18
|
+
'clauseNames' => ['description'],
|
19
|
+
'schema' => {
|
20
|
+
'type' => 'string',
|
21
|
+
'system' => 'description'
|
22
|
+
}
|
25
23
|
}
|
26
24
|
end
|
27
25
|
|
28
26
|
let(:expected_collection_length) { 2 }
|
29
27
|
|
30
|
-
it_should_behave_like
|
31
|
-
it_should_behave_like
|
32
|
-
it_should_behave_like
|
33
|
-
|
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'
|
34
31
|
end
|
35
32
|
end
|