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,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
- def self.all(client, key)
12
- response = client.get(path_base(client) + '/sprintquery/' + key.to_s)
13
- parse_json(response.body)
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 self.find(client, key, options = {})
17
- options[:maxResults] ||= 100
18
- fields = options[:fields].join(',') unless options[:fields].nil?
19
- response = client.get("/rest/api/latest/search?jql=sprint=#{key}&fields=#{fields}&maxResults=#{options[:maxResults]}")
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
- private
26
+ def sprint_report
27
+ get_sprint_details_attribute('sprint_report')
28
+ end
24
29
 
25
- def self.path_base(client)
26
- client.options[:context_path] + '/rest/greenhopper/1.0'
30
+ def start_date
31
+ get_sprint_details_attribute('start_date')
27
32
  end
28
33
 
29
- def path_base(client)
30
- self.class.path_base(client)
34
+ def end_date
35
+ get_sprint_details_attribute('end_date')
31
36
  end
32
37
 
33
- end
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
@@ -0,0 +1,8 @@
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
@@ -1,10 +1,8 @@
1
1
  module JIRA
2
2
  module Resource
3
-
4
3
  class StatusFactory < JIRA::BaseFactory # :nodoc:
5
4
  end
6
5
 
7
- class Status < JIRA::Base ; end
8
-
6
+ class Status < JIRA::Base; end
9
7
  end
10
8
  end
@@ -0,0 +1,9 @@
1
+ module JIRA
2
+ module Resource
3
+ class SuggestedIssueFactory < JIRA::BaseFactory # :nodoc:
4
+ end
5
+
6
+ class SuggestedIssue < JIRA::Base
7
+ end
8
+ end
9
+ end
@@ -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, :class => JIRA::Resource::Status
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
@@ -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
@@ -1,10 +1,8 @@
1
1
  module JIRA
2
2
  module Resource
3
-
4
3
  class VersionFactory < JIRA::BaseFactory # :nodoc:
5
4
  end
6
5
 
7
- class Version < JIRA::Base ; end
8
-
6
+ class Version < JIRA::Base; end
9
7
  end
10
8
  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
- self.full_url(client) + prefix + self.endpoint_name
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
- self.new(client, {:attrs => attrs}.merge(options))
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, :class => JIRA::Resource::User
9
- has_one :update_author, :class => JIRA::Resource::User,
10
- :attribute_key => "updateAuthor"
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
@@ -1,3 +1,3 @@
1
1
  module JIRA
2
- VERSION = "1.2.0"
2
+ VERSION = '2.3.0'.freeze
3
3
  end
data/lib/jira-ruby.rb CHANGED
@@ -1,5 +1,6 @@
1
- $: << File.expand_path(File.dirname(__FILE__))
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/sprint'
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)
@@ -1,18 +1,18 @@
1
1
  require 'securerandom'
2
2
 
3
3
  namespace :jira do
4
- desc "Generate a consumer key for your application"
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 "Run the system call to generate a RSA public certificate"
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 "You will need to copy the following certificate into your application link configuration in Jira:"
16
- system("cat rsacert.pem")
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) { "10000" }
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' => "http://localhost:2990/jira/rest/api/2/attachment/10000",
14
- 'size' => 15360,
15
- 'filename' => "ballmer.png"
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
- it_should_behave_like "a resource"
20
- it_should_behave_like "a resource with a singular GET endpoint"
21
- it_should_behave_like "a resource with a DELETE endpoint"
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) { "10000" }
8
+ let(:key) { '10000' }
10
9
 
11
- let(:target) { JIRA::Resource::Comment.new(client, :attrs => {'id' => '99999'}, :issue_id => '54321') }
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, :attrs => {
17
- 'id' => '10002',
18
- 'fields' => {
19
- 'comment' => {'comments' => []}
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' => "http://localhost:2990/jira/rest/api/2/issue/10002/comment/10000",
25
+ 'self' => 'http://localhost:2990/jira/rest/api/2/issue/10002/comment/10000',
27
26
  'id' => key,
28
- 'body' => "This is a comment. Creative."
27
+ 'body' => 'This is a comment. Creative.'
29
28
  }
30
29
  end
31
30
 
32
- let(:attributes_for_post) {
33
- { "body" => "new comment" }
34
- }
35
- let(:expected_attributes_from_post) {
36
- { "id" => "10001", "body" => "new comment"}
37
- }
38
-
39
- let(:attributes_for_put) {
40
- {"body" => "new body"}
41
- }
42
- let(:expected_attributes_from_put) {
43
- { "id" => "10000", "body" => "new body" }
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) { "10000" }
8
+ let(:key) { '10000' }
11
9
 
12
10
  let(:expected_attributes) do
13
11
  {
14
- 'self' => "http://localhost:2990/jira/rest/api/2/component/10000",
12
+ 'self' => 'http://localhost:2990/jira/rest/api/2/component/10000',
15
13
  'id' => key,
16
- 'name' => "Cheesecake"
14
+ 'name' => 'Cheesecake'
17
15
  }
18
16
  end
19
17
 
20
- let(:attributes_for_post) {
21
- {"name" => "Test component", "project" => "SAMPLEPROJECT" }
22
- }
23
- let(:expected_attributes_from_post) {
24
- { "id" => "10001", "name" => "Test component" }
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
- it_should_behave_like "a resource"
35
- it_should_behave_like "a resource with a singular GET endpoint"
36
- it_should_behave_like "a resource with a DELETE endpoint"
37
- it_should_behave_like "a resource with a POST endpoint"
38
- it_should_behave_like "a resource with a PUT endpoint"
39
- it_should_behave_like "a resource with a PUT endpoint that rejects invalid fields"
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
- "id"=>key,
15
- "name"=>"Description",
16
- "custom"=>false,
17
- "orderable"=>true,
18
- "navigable"=>true,
19
- "searchable"=>true,
20
- "clauseNames"=>["description"],
21
- "schema"=> {
22
- "type"=>"string",
23
- "system"=>"description"
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 "a resource"
31
- it_should_behave_like "a resource with a collection GET endpoint"
32
- it_should_behave_like "a resource with a singular GET endpoint"
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