jira-ruby 1.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 72616e61b52a45892a4fa86713ca5c9847440c42
4
- data.tar.gz: 7aae22f02bcf7c91bb0dff21e5d55aa3ba828eee
3
+ metadata.gz: 938fec5653ff3c6dc1d696e9fcdf9b48035d27ab
4
+ data.tar.gz: 2f970d1175362e3ffd53a4f7136ae23396667e5d
5
5
  SHA512:
6
- metadata.gz: a9b54e4bd78bb5aef39937772720382c79c221caa7bcfa711dd7a3eddd80f047b60d51874bb61ecd4489a28030f840125bbb713c7e75aa5e75a24f6017f7b76f
7
- data.tar.gz: 66bbc3c25c56c03d37a00ffa38d520c8842f50e614ae96007b8202c0050cd8954189cf97e3ba62dcbb7ca9f0a8092815d723f2dc078ec126a0aab72bba5c4a33
6
+ metadata.gz: 87c5a7dcd5a1a501cd00a65c4e60d52b0dcf30a176c91d35349560b9c99866db3fbea8b7c9f89fc5897564b77d049c3b38e8d09ef3eb151024d8892385e005bc
7
+ data.tar.gz: ffc1d13d012b554794ee562d353e5ea9b7ea4d7d366264a6ced2e0838f10443cbbb5dd689a2173fb702aad0c343bd755a118e986e4d67413ec1272271aae0452
@@ -0,0 +1 @@
1
+ 2.3.3
@@ -5,6 +5,10 @@
5
5
 
6
6
  This gem provides access to the Atlassian JIRA REST API.
7
7
 
8
+ == Slack
9
+
10
+ Join our Slack channel! You can find us here[http://jira-ruby.slack.com]
11
+
8
12
  == Example usage
9
13
 
10
14
  require 'rubygems'
data/example.rb CHANGED
@@ -59,11 +59,12 @@ old_way = issue.customfield_12345
59
59
  new_way = issue.Special_Field
60
60
  (old_way == new_way) && puts 'much easier'
61
61
  #
62
- # Can also use this to specify fields to be returned in the response
63
- client.Issue.jql(a_normal_jql_search, fields:[:Special_Field])
64
- # Or you could always do it the old way - if you can remember the numbers...
65
- client.Issue.jql(a_normal_jql_search, fields:['customfield_12345'])
66
- # You can specify the maximum number of results to be returned in the response, i.e. 500
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
67
68
  client.Issue.jql(a_normal_jql_search, max_results: 500)
68
69
 
69
70
  # # Find a specific project by key
@@ -108,6 +109,15 @@ client.Issue.jql(a_normal_jql_search, max_results: 500)
108
109
  # issue.save({"fields"=>{"summary"=>"EVEN MOOOOOOARRR NINJAAAA!"}})
109
110
  # pp issue
110
111
  #
112
+ # # Transition an issue
113
+ # # -------------------
114
+ # issue_transition = issue.transitions.build
115
+ # issue_transition.save!('transition' => {'id' => transition_id})
116
+ #
117
+ # # Change assignee
118
+ # # -------------------
119
+ # issue.save({'fields' => {'assignee' => {'name' => person_name}}})
120
+ #
111
121
  # # Find a user
112
122
  # # -----------
113
123
  # user = client.User.find('admin')
@@ -51,7 +51,7 @@ end
51
51
  #
52
52
  # # List issues by JQL query
53
53
  # # ------------------------
54
- # client.Issue.jql('PROJECT = "SAMPLEPROJECT"', [comments, summary]).each do |issue|
54
+ # client.Issue.jql('PROJECT = "SAMPLEPROJECT"', {fields: %w(summary status)}).each do |issue|
55
55
  # puts "#{issue.id} - #{issue.fields['summary']}"
56
56
  # end
57
57
  #
@@ -500,8 +500,12 @@ module JIRA
500
500
  end
501
501
 
502
502
  def hash_to_query_string(query_params)
503
+ self.class.hash_to_query_string(query_params)
504
+ end
505
+
506
+ def self.hash_to_query_string(query_params)
503
507
  query_params.map do |k,v|
504
- CGI.escape(k.to_s) + "=" + CGI.escape(v.to_s)
508
+ CGI.escape(k.to_s) + '=' + CGI.escape(v.to_s)
505
509
  end.join('&')
506
510
  end
507
511
 
@@ -37,16 +37,10 @@ module JIRA
37
37
  response = params.empty? ? client.get("#{create_meta_url}") : client.get("#{create_meta_url}?#{params}")
38
38
 
39
39
  json = parse_json(response.body)
40
- self.new(client, {:attrs => json['projects']})
41
- end
42
-
43
- def self.hash_to_query_string(query_params)
44
- query_params.map do |k,v|
45
- CGI.escape(k.to_s) + '=' + CGI.escape(v.to_s)
46
- end.join('&')
40
+ json['projects'].map do |attrs|
41
+ self.new(client, {:attrs => attrs})
42
+ end
47
43
  end
48
-
49
44
  end
50
-
51
45
  end
52
46
  end
@@ -27,9 +27,11 @@ module JIRA
27
27
  end
28
28
  end
29
29
 
30
- def users
30
+ def users(start_at: nil, max_results: nil)
31
31
  users_url = client.options[:rest_base_path] + '/user/assignable/search'
32
- query_params = {:project => self.key_value}
32
+ query_params = { project: self.key_value }
33
+ query_params['startAt'] = start_at if start_at
34
+ query_params['maxResults'] = max_results if max_results
33
35
  response = client.get(url_with_query_params(users_url, query_params))
34
36
  json = self.class.parse_json(response.body)
35
37
  json.map do |jira_user|
@@ -1,3 +1,3 @@
1
1
  module JIRA
2
- VERSION = "1.1.3"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -13,7 +13,7 @@ describe JIRA::Resource::Createmeta do
13
13
  let(:response) {
14
14
  double(
15
15
  'response',
16
- :body => '{"expand":"projects","projects":[{"self":"http://localhost:2029/rest/api/2/project/TST"}]}'
16
+ :body => '{"expand":"projects","projects":[{"self":"http://localhost:2029/rest/api/2/project/TST","id":"10200","key":"test_key","name":"Test Name"}]}'
17
17
  )
18
18
  }
19
19
 
@@ -33,9 +33,17 @@ describe JIRA::Resource::Createmeta do
33
33
  JIRA::Resource::Createmeta.all(client, :foo => 'bar')
34
34
  end
35
35
 
36
+ it 'should return an array of createmeta objects' do
37
+ expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta').and_return(response)
38
+ createmetas = JIRA::Resource::Createmeta.all(client)
39
+ expect(createmetas).to be_an Array
40
+ createmeta = createmetas.first
41
+ expect(createmeta.id).to eq '10200'
42
+ expect(createmeta.key).to eq 'test_key'
43
+ expect(createmeta.name).to eq 'Test Name'
44
+ end
36
45
  end
37
46
 
38
-
39
47
  describe 'projectKeys' do
40
48
  it 'should query correct url when only one `projectKeys` given as string' do
41
49
  expect(client).to receive(:get).with('/jira/rest/api/2/issue/createmeta?projectKeys=PROJECT_1').and_return(response)
@@ -250,4 +258,4 @@ describe JIRA::Resource::Createmeta do
250
258
  )
251
259
  end
252
260
  end
253
- end
261
+ end
@@ -67,4 +67,57 @@ describe JIRA::Resource::Project do
67
67
  end
68
68
  end
69
69
  end
70
+
71
+ describe 'users' do
72
+ let(:project) { JIRA::Resource::Project.new(client, attrs: { 'key' => project_key }) }
73
+ let(:project_key) { SecureRandom.hex }
74
+ let(:response) { double('response', body: '[{}]') }
75
+
76
+ context 'pagination' do
77
+ before(:each) do
78
+ user_factory = double('user factory')
79
+ expect(client).to receive(:User).and_return(user_factory)
80
+ expect(user_factory).to receive(:build).with(any_args)
81
+ end
82
+
83
+ it 'doesn\'t use pagination parameters by default' do
84
+ expect(client).to receive(:get)
85
+ .with("/jira/rest/api/2/user/assignable/search?project=#{project_key}")
86
+ .and_return(response)
87
+
88
+ project.users
89
+ end
90
+
91
+ it 'accepts start_at option' do
92
+ start_at = rand(1000)
93
+
94
+ expect(client).to receive(:get)
95
+ .with("/jira/rest/api/2/user/assignable/search?project=#{project_key}&startAt=#{start_at}")
96
+ .and_return(response)
97
+
98
+ project.users(start_at: start_at)
99
+ end
100
+
101
+ it 'accepts max_results option' do
102
+ max_results = rand(1000)
103
+
104
+ expect(client).to receive(:get)
105
+ .with("/jira/rest/api/2/user/assignable/search?project=#{project_key}&maxResults=#{max_results}")
106
+ .and_return(response)
107
+
108
+ project.users(max_results: max_results)
109
+ end
110
+
111
+ it 'accepts start_at and max_results options' do
112
+ start_at = rand(1000)
113
+ max_results = rand(1000)
114
+
115
+ expect(client).to receive(:get)
116
+ .with("/jira/rest/api/2/user/assignable/search?project=#{project_key}&startAt=#{start_at}&maxResults=#{max_results}")
117
+ .and_return(response)
118
+
119
+ project.users(start_at: start_at, max_results: max_results)
120
+ end
121
+ end
122
+ end
70
123
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jira-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SUMO Heavy Industries
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-13 00:00:00.000000000 Z
11
+ date: 2016-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth
@@ -185,6 +185,7 @@ extensions: []
185
185
  extra_rdoc_files: []
186
186
  files:
187
187
  - ".gitignore"
188
+ - ".ruby-version"
188
189
  - ".travis.yml"
189
190
  - Gemfile
190
191
  - Guardfile
@@ -341,7 +342,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
341
342
  version: '0'
342
343
  requirements: []
343
344
  rubyforge_project: jira-ruby
344
- rubygems_version: 2.6.4
345
+ rubygems_version: 2.5.2
345
346
  signing_key:
346
347
  specification_version: 4
347
348
  summary: Ruby Gem for use with the Atlassian JIRA REST API