Skip to content

Commit cf52189

Browse files
Revert "IE 1122 update deprecated jira apis" (#25)
* Revert "IE 1122 update deprecated jira apis (#24)" This reverts commit aa6813f. * github action updated in rspec
1 parent aa6813f commit cf52189

20 files changed

Lines changed: 44 additions & 299 deletions

README.rdoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ Here's the same example as a Sinatra application:
235235
:access_token_path => "/plugins/servlet/oauth/access-token",
236236
:private_key_file => "rsakey.pem",
237237
:rest_base_path => "/rest/api/2",
238-
:rest_base_path_v3 => "/rest/api/3",
239238
:consumer_key => "jira-ruby-example"
240239
}
241240

lib/jira/client.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class Client
5050
:site => 'http://localhost:2990',
5151
:context_path => '/jira',
5252
:rest_base_path => "/rest/api/2",
53-
:rest_base_path_v3 => "/rest/api/3",
5453
:ssl_verify_mode => OpenSSL::SSL::VERIFY_PEER,
5554
:use_ssl => true,
5655
:auth_type => :oauth,
@@ -61,7 +60,6 @@ def initialize(options={})
6160
options = DEFAULT_OPTIONS.merge(options)
6261
@options = options
6362
@options[:rest_base_path] = @options[:context_path] + @options[:rest_base_path]
64-
@options[:rest_base_path_v3] = @options[:context_path] + @options[:rest_base_path_v3]
6563

6664
case options[:auth_type]
6765
when :oauth

lib/jira/resource/issue.rb

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,15 @@ class Issue < JIRA::Base
4747
has_many :remotelink, :class => JIRA::Resource::Remotelink
4848

4949
def self.all(client)
50-
url = client.options[:rest_base_path_v3] + '/search/jql?expand=transitions.fields'
50+
url = client.options[:rest_base_path] + "/search?expand=transitions.fields"
5151
response = client.get(url)
5252
json = parse_json(response.body)
5353
json['issues'].map do |issue|
5454
client.Issue.build(issue)
5555
end
5656
end
5757

58-
59-
def self.jql_v2(client, jql, options = {fields: nil, start_at: nil, max_results: nil, expand: nil})
58+
def self.jql(client, jql, options = {fields: nil, start_at: nil, max_results: nil, expand: nil})
6059
url = client.options[:rest_base_path] + "/search?jql=" + CGI.escape(jql)
6160

6261
url << "&fields=#{options[:fields].map{ |value| CGI.escape(client.Field.name_to_id(value)) }.join(',')}" if options[:fields]
@@ -75,29 +74,6 @@ def self.jql_v2(client, jql, options = {fields: nil, start_at: nil, max_results:
7574
end
7675
end
7776

78-
def self.jql(client, jql, options = {fields: nil, next_page_token: nil, max_results: nil, expand: nil})
79-
url = client.options[:rest_base_path_v3] + "/search/jql?jql=" + CGI.escape(jql)
80-
81-
url << "&fields=#{options[:fields].map{ |value| CGI.escape(client.Field.name_to_id(value)) }.join(',')}" if options[:fields]
82-
url << "&nextPageToken=#{CGI.escape(options[:next_page_token].to_s)}" if options[:next_page_token]
83-
url << "&maxResults=#{CGI.escape(options[:max_results].to_s)}" if options[:max_results]
84-
85-
if options[:expand]
86-
options[:expand] = [options[:expand]] if options[:expand].is_a?(String)
87-
url << "&expand=#{options[:expand].to_a.map{ |value| CGI.escape(value.to_s) }.join(',')}"
88-
end
89-
90-
response = client.get(url)
91-
json = parse_json(response.body)
92-
result = {}
93-
result['next_page_token'] = json['nextPageToken'] if json['nextPageToken'] rescue nil
94-
result['issues'] = json['issues'].map do |issue|
95-
client.Issue.build(issue)
96-
97-
end
98-
result
99-
end
100-
10177
def editmeta
10278
editmeta_url = client.options[:rest_base_path] + "/#{self.class.endpoint_name}/#{key}/editmeta"
10379

lib/jira/resource/project.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def self.key_attribute
1717

1818
# Returns all the issues for this project
1919
def issues(options={})
20-
search_url = client.options[:rest_base_path_v3] + "/search/jql"
20+
search_url = client.options[:rest_base_path] + '/search'
2121
query_params = {:jql => "project=\"#{key}\""}
2222
query_params.update Base.query_params_for_search(options)
2323
response = client.get(url_with_query_params(search_url, query_params))

lib/jira/resource/rapidview.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ def issues(options = {})
3232
jql = "id IN(#{issue_ids.join(', ')})"
3333

3434
# Filtering options
35-
jql << " AND sprint IS NOT EMPTY" unless options[:include_backlog_items]
35+
jql << " AND sprint IS NOT EMPTY" unless options[:include_backlog_items]
3636

37-
parent_issues = client.Issue.jql(jql)["issues"]
37+
parent_issues = client.Issue.jql(jql)
3838
subtask_ids = parent_issues.map { |t| t.subtasks.map { |sub| sub['id'] } }.flatten
3939

4040
parent_and_sub_ids = parent_issues.map(&:id) + subtask_ids

spec/integration/comment_spec.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,7 @@
4242
let(:expected_attributes_from_put) {
4343
{ "id" => "10000", "body" => "new body" }
4444
}
45-
before(:each) do
46-
stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/2/comment")
47-
.with(headers: {
48-
'Accept'=>'application/json',
49-
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
50-
'User-Agent'=>'Ruby'
51-
})
52-
.to_return(:status => 200, :body => '{"comments":[{"self":"http://localhost:2990/jira/rest/api/2/issue/10002/comment/10000","id":"10000","body":"This is a comment. Creative."},{"self":"http://localhost:2990/jira/rest/api/2/issue/10002/comment/10001","id":"10001","body":"Another comment."}]}', :headers => {})
53-
end
45+
5446
it_should_behave_like "a resource"
5547
it_should_behave_like "a resource with a collection GET endpoint"
5648
it_should_behave_like "a resource with a singular GET endpoint"

spec/integration/field_spec.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,7 @@
2626
end
2727

2828
let(:expected_collection_length) { 2 }
29-
before(:each) do
30-
stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/2/field")
31-
.with(headers: {
32-
'Accept'=>'application/json',
33-
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
34-
'User-Agent'=>'Ruby'
35-
})
36-
.to_return(:status => 200, :body => '[{"id":"1","name":"Description","custom":false,"orderable":true,"navigable":true,"searchable":true,"clauseNames":["description"],"schema":{"type":"string","system":"description"}},{"id":"2","name":"Summary","custom":false,"orderable":true,"navigable":true,"searchable":true,"clauseNames":["summary"],"schema":{"type":"string","system":"summary"}}]', :headers => {})
37-
end
29+
3830
it_should_behave_like "a resource"
3931
it_should_behave_like "a resource with a collection GET endpoint"
4032
it_should_behave_like "a resource with a singular GET endpoint"

spec/integration/issue_spec.rb

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
}
4747
}
4848
before(:each) do
49-
stub_request(:get, site_url + "/jira/rest/api/3/search/jql?expand=transitions.fields").
49+
stub_request(:get, site_url + "/jira/rest/api/2/search?expand=transitions.fields").
5050
to_return(:status => 200, :body => get_mock_response('issue.json'))
5151
end
5252
it_should_behave_like "a resource with a collection GET endpoint"
@@ -55,8 +55,8 @@
5555
it_should_behave_like "a resource with a POST endpoint"
5656
it_should_behave_like "a resource with a PUT endpoint"
5757
it_should_behave_like "a resource with a PUT endpoint that rejects invalid fields"
58+
5859
describe "errors" do
59-
6060
before(:each) do
6161
stub_request(:get,
6262
site_url + "/jira/rest/api/2/issue/10002").
@@ -87,25 +87,6 @@
8787
"key"=>"SAMPLEPROJECT-13"
8888
}
8989
}
90-
91-
before(:each) do
92-
93-
stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/3/search/jql?jql=PROJECT%20=%20'SAMPLEPROJECT'")
94-
.with(headers: {
95-
'Accept'=>'application/json',
96-
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
97-
'User-Agent'=>'Ruby'
98-
})
99-
.to_return(status: 200, body: get_mock_response('issue.json'), headers: {})
100-
stub_request(:get, site_url + "/jira/rest/api/3/search/jql?jql=PROJECT%20=%20'SAMPLEPROJECT'")
101-
.with(headers: {
102-
'Accept'=>'application/json',
103-
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
104-
'Authorization'=>/OAuth .*/, # Use a regex to match any OAuth header
105-
'User-Agent'=>'OAuth gem v0.5.14'
106-
})
107-
.to_return(status: 200, body: get_mock_response('issue.json'), headers: {})
108-
end
10990
it_should_behave_like "a resource with JQL inputs and a collection GET endpoint"
11091
end
11192

spec/integration/issuelinktype_spec.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,6 @@
22

33
describe JIRA::Resource::Issuelinktype do
44

5-
before(:each) do
6-
stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/2/issueLinkType")
7-
.with(headers: {
8-
'Accept'=>'application/json',
9-
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
10-
'User-Agent'=>'Ruby'
11-
})
12-
.to_return(
13-
:status => 200,
14-
:body => '{"issueLinkTypes":[{"id":"10000","self":"http://localhost:2990/jira/rest/api/2/issueLinkType/10000","name":"Blocks","inward":"is blocked by","outward":"blocks"},{"id":"10001","self":"http://localhost:2990/jira/rest/api/2/issueLinkType/10001","name":"Relates","inward":"relates to","outward":"relates to"},{"id":"10002","self":"http://localhost:2990/jira/rest/api/2/issueLinkType/10002","name":"Duplicates","inward":"is duplicated by","outward":"duplicates"}]}',
15-
:headers => {}
16-
)
17-
end
18-
195
with_each_client do |site_url, client|
206
let(:client) { client }
217
let(:site_url) { site_url }

spec/integration/issuetype_spec.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@
1818

1919
let(:expected_collection_length) { 5 }
2020

21-
before(:each) do
22-
stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/2/issuetype")
23-
.with(headers: {
24-
'Accept'=>'application/json',
25-
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
26-
'User-Agent'=>'Ruby'
27-
})
28-
.to_return(:status => 200, :body => '[{"self":"http://localhost:2990/jira/rest/api/2/issuetype/5","id":"5","name":"Sub-task"},{"self":"http://localhost:2990/jira/rest/api/2/issuetype/1","id":"1","name":"Bug"},{"self":"http://localhost:2990/jira/rest/api/2/issuetype/2","id":"2","name":"Task"},{"self":"http://localhost:2990/jira/rest/api/2/issuetype/3","id":"3","name":"Story"},{"self":"http://localhost:2990/jira/rest/api/2/issuetype/4","id":"4","name":"Epic"}]', :headers => {})
29-
end
30-
3121
it_should_behave_like "a resource"
3222
it_should_behave_like "a resource with a collection GET endpoint"
3323
it_should_behave_like "a resource with a singular GET endpoint"

0 commit comments

Comments
 (0)