From 561cad3712d3bd28fee511f1e77d39be96863731 Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Mon, 28 Jul 2025 20:39:57 +0530 Subject: [PATCH 01/21] initial commit for new apis jira --- README.rdoc | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rdoc b/README.rdoc index ed10f83f..9f4f4ae0 100644 --- a/README.rdoc +++ b/README.rdoc @@ -235,6 +235,7 @@ Here's the same example as a Sinatra application: :access_token_path => "/plugins/servlet/oauth/access-token", :private_key_file => "rsakey.pem", :rest_base_path => "/rest/api/2", + :rest_base_path_v3 => "/rest/api/3", :consumer_key => "jira-ruby-example" } From 4c488045ebdf540a973e17bd92c267c596bb9303 Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Mon, 28 Jul 2025 21:39:24 +0530 Subject: [PATCH 02/21] change into new urls for search --- lib/jira/client.rb | 1 + lib/jira/resource/issue.rb | 4 ++-- lib/jira/resource/project.rb | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/jira/client.rb b/lib/jira/client.rb index 0ce3d5d7..b6003b68 100644 --- a/lib/jira/client.rb +++ b/lib/jira/client.rb @@ -50,6 +50,7 @@ class Client :site => 'http://localhost:2990', :context_path => '/jira', :rest_base_path => "/rest/api/2", + :rest_base_path_v3 => "/rest/api/3", :ssl_verify_mode => OpenSSL::SSL::VERIFY_PEER, :use_ssl => true, :auth_type => :oauth, diff --git a/lib/jira/resource/issue.rb b/lib/jira/resource/issue.rb index 96d75204..36ca58a2 100644 --- a/lib/jira/resource/issue.rb +++ b/lib/jira/resource/issue.rb @@ -47,7 +47,7 @@ class Issue < JIRA::Base has_many :remotelink, :class => JIRA::Resource::Remotelink def self.all(client) - url = client.options[:rest_base_path] + "/search?expand=transitions.fields" + url = client.options[:rest_base_path_v3] + '/search/jql?expand=transitions.fields' response = client.get(url) json = parse_json(response.body) json['issues'].map do |issue| @@ -56,7 +56,7 @@ def self.all(client) end def self.jql(client, jql, options = {fields: nil, start_at: nil, max_results: nil, expand: nil}) - url = client.options[:rest_base_path] + "/search?jql=" + CGI.escape(jql) + url = client.options[:rest_base_path_v3] + "/search/jql?jql=" + CGI.escape(jql) url << "&fields=#{options[:fields].map{ |value| CGI.escape(client.Field.name_to_id(value)) }.join(',')}" if options[:fields] url << "&startAt=#{CGI.escape(options[:start_at].to_s)}" if options[:start_at] diff --git a/lib/jira/resource/project.rb b/lib/jira/resource/project.rb index 8248db16..3fa0c9bf 100644 --- a/lib/jira/resource/project.rb +++ b/lib/jira/resource/project.rb @@ -17,7 +17,7 @@ def self.key_attribute # Returns all the issues for this project def issues(options={}) - search_url = client.options[:rest_base_path] + '/search' + search_url = client.options[:rest_base_path_v3] + "/search/jql" query_params = {:jql => "project=\"#{key}\""} query_params.update Base.query_params_for_search(options) response = client.get(url_with_query_params(search_url, query_params)) From adeeda38e07925d1dd2a2b1531af158daf67b44f Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Mon, 28 Jul 2025 22:00:36 +0530 Subject: [PATCH 03/21] actions updated --- .github/workflows/rspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rspec.yaml b/.github/workflows/rspec.yaml index 6a2f1ee7..6235fdda 100644 --- a/.github/workflows/rspec.yaml +++ b/.github/workflows/rspec.yaml @@ -10,11 +10,11 @@ jobs: image: ruby:3.0.6 steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Gem cache id: cache-bundle - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: vendor/bundle key: bundle-${{ hashFiles('**/Gemfile.lock') }} From cf300e7c073e9639f8765c7dd9505f7618b792c6 Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Tue, 29 Jul 2025 23:56:24 +0530 Subject: [PATCH 04/21] some test fixes --- spec/integration/issue_spec.rb | 37 +++++++++++++++++- spec/integration/issuelinktype_spec.rb | 14 +++++++ spec/integration/priority_spec.rb | 10 +++++ spec/integration/project_spec.rb | 10 +++++ spec/integration/rapidview_spec.rb | 24 ++++++++++-- spec/integration/status_spec.rb | 10 +++++ spec/integration/worklog_spec.rb | 10 +++++ spec/jira/resource/filter_spec.rb | 6 +-- spec/jira/resource/issue_spec.rb | 26 +++++++++---- spec/jira/resource/project_spec.rb | 14 ++++++- spec/spec_helper.rb | 43 +++++++++++++++++++++ spec/support/shared_examples/integration.rb | 4 +- 12 files changed, 189 insertions(+), 19 deletions(-) diff --git a/spec/integration/issue_spec.rb b/spec/integration/issue_spec.rb index 39cc0c7d..50409935 100644 --- a/spec/integration/issue_spec.rb +++ b/spec/integration/issue_spec.rb @@ -46,9 +46,25 @@ } } before(:each) do - stub_request(:get, site_url + "/jira/rest/api/2/search?expand=transitions.fields"). + stub_request(:get, site_url + "/jira/rest/api/3/search/jql?expand=transitions.fields"). to_return(:status => 200, :body => get_mock_response('issue.json')) - end + + stub_request(:get, "http://localhost:2990/rest/api/3/search/jql?expand=transitions.fields") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'Authorization'=>/OAuth .*/, # Use a regex to match any OAuth header + 'User-Agent'=>'OAuth gem v0.5.14' + }) + .to_return(status: 200, body: get_mock_response('issue.json'), headers: {}) + stub_request(:get, "http://foo:bar@localhost:2990/rest/api/3/search/jql?expand=transitions.fields") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent'=>'Ruby' + }) + .to_return(status: 200, body: get_mock_response('issue.json'), headers: {}) + end it_should_behave_like "a resource with a collection GET endpoint" end it_should_behave_like "a resource with a DELETE endpoint" @@ -87,6 +103,23 @@ "key"=>"SAMPLEPROJECT-13" } } + before(:each) do + stub_request(:get, "http://foo:bar@localhost:2990/rest/api/3/search/jql?jql=PROJECT%20=%20'SAMPLEPROJECT'") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent'=>'Ruby' + }) + .to_return(status: 200, body: get_mock_response('issue.json'), headers: {}) + stub_request(:get, "http://localhost:2990/rest/api/3/search/jql?jql=PROJECT%20=%20'SAMPLEPROJECT'") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'Authorization'=>/OAuth .*/, # Use a regex to match any OAuth header + 'User-Agent'=>'OAuth gem v0.5.14' + }) + .to_return(status: 200, body: get_mock_response('issue.json'), headers: {}) + end it_should_behave_like "a resource with JQL inputs and a collection GET endpoint" end diff --git a/spec/integration/issuelinktype_spec.rb b/spec/integration/issuelinktype_spec.rb index dedff7f2..4f914b4b 100644 --- a/spec/integration/issuelinktype_spec.rb +++ b/spec/integration/issuelinktype_spec.rb @@ -2,6 +2,20 @@ describe JIRA::Resource::Issuelinktype do + before(:each) do + stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/2/issueLinkType") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent'=>'Ruby' + }) + .to_return( + :status => 200, + :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"}]}', + :headers => {} + ) + end + with_each_client do |site_url, client| let(:client) { client } let(:site_url) { site_url } diff --git a/spec/integration/priority_spec.rb b/spec/integration/priority_spec.rb index d96a068f..bc528bdd 100644 --- a/spec/integration/priority_spec.rb +++ b/spec/integration/priority_spec.rb @@ -2,6 +2,16 @@ describe JIRA::Resource::Priority do + before(:each) do + stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/2/priority") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent'=>'Ruby' + }) + .to_return(:status => 200, :body => '[{"self":"http://localhost:2990/jira/rest/api/2/priority/1","id":"1","name":"Blocker"},{"self":"http://localhost:2990/jira/rest/api/2/priority/2","id":"2","name":"Critical"},{"self":"http://localhost:2990/jira/rest/api/2/priority/3","id":"3","name":"Major"},{"self":"http://localhost:2990/jira/rest/api/2/priority/4","id":"4","name":"Minor"},{"self":"http://localhost:2990/jira/rest/api/2/priority/5","id":"5","name":"Trivial"}]', :headers => {}) + end + with_each_client do |site_url, client| let(:client) { client } let(:site_url) { site_url } diff --git a/spec/integration/project_spec.rb b/spec/integration/project_spec.rb index 72337e54..cedbd4d7 100644 --- a/spec/integration/project_spec.rb +++ b/spec/integration/project_spec.rb @@ -52,5 +52,15 @@ end end + + before(:each) do + stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/2/project") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent'=>'Ruby' + }) + .to_return(:status => 200, :body => get_mock_from_path(:get), :headers => {}) + end end end diff --git a/spec/integration/rapidview_spec.rb b/spec/integration/rapidview_spec.rb index 67b3c0e4..54b0647c 100644 --- a/spec/integration/rapidview_spec.rb +++ b/spec/integration/rapidview_spec.rb @@ -30,6 +30,7 @@ before(:each) do stub_request(:get, site_url + '/jira/rest/greenhopper/1.0/rapidview'). to_return(:status => 200, :body => get_mock_response('rapidview.json')) + end it_should_behave_like 'a resource with a collection GET endpoint' end @@ -44,10 +45,27 @@ :status => 200, :body => get_mock_response('rapidview/SAMPLEPROJECT.issues.json') ) - + stub_request(:get, "http://localhost:2990/rest/api/3/search/jql?jql=id%20IN(10000,%2010001)%20AND%20sprint%20IS%20NOT%20EMPTY") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'Authorization'=>/OAuth .*/, + 'User-Agent'=>'OAuth gem v0.5.14' + }) + .to_return(status: 200, body: get_mock_response('rapidview/SAMPLEPROJECT.issues.full.json'), headers: {}) + stub_request( + :get, + "http://localhost:2990/rest/api/3/search/jql?jql=id%20IN(10001,%2010000)" + ).with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'Authorization'=>/OAuth .*/, + 'User-Agent'=>'OAuth gem v0.5.14' + }) + .to_return(status: 200, body: get_mock_response('rapidview/SAMPLEPROJECT.issues.full.json'), headers: {}) stub_request( :get, - site_url + '/jira/rest/api/2/search?jql=id IN(10000, 10001)%20AND%20sprint%20IS%20NOT%20EMPTY' + 'http://foo:bar@localhost:2990' + '/rest/api/3/search/jql?jql=id IN(10000, 10001)%20AND%20sprint%20IS%20NOT%20EMPTY' ).to_return( :status => 200, :body => get_mock_response('rapidview/SAMPLEPROJECT.issues.full.json') @@ -55,7 +73,7 @@ stub_request( :get, - site_url + '/jira/rest/api/2/search?jql=id IN(10001, 10000)' + 'http://foo:bar@localhost:2990' + '/rest/api/3/search/jql?jql=id IN(10001, 10000)' ).to_return( :status => 200, :body => get_mock_response('rapidview/SAMPLEPROJECT.issues.full.json') diff --git a/spec/integration/status_spec.rb b/spec/integration/status_spec.rb index ec2662a2..b5f00fb9 100644 --- a/spec/integration/status_spec.rb +++ b/spec/integration/status_spec.rb @@ -2,6 +2,16 @@ describe JIRA::Resource::Status do + before(:each) do + stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/2/status") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent'=>'Ruby' + }) + .to_return(:status => 200, :body => '[{"self":"http://localhost:2990/jira/rest/api/2/status/1","id":"1","name":"Open"},{"self":"http://localhost:2990/jira/rest/api/2/status/2","id":"2","name":"In Progress"},{"self":"http://localhost:2990/jira/rest/api/2/status/3","id":"3","name":"Resolved"},{"self":"http://localhost:2990/jira/rest/api/2/status/4","id":"4","name":"Closed"},{"self":"http://localhost:2990/jira/rest/api/2/status/5","id":"5","name":"Reopened"}]', :headers => {}) + end + with_each_client do |site_url, client| let(:client) { client } let(:site_url) { site_url } diff --git a/spec/integration/worklog_spec.rb b/spec/integration/worklog_spec.rb index 944869a3..5164d9fa 100644 --- a/spec/integration/worklog_spec.rb +++ b/spec/integration/worklog_spec.rb @@ -2,6 +2,16 @@ describe JIRA::Resource::Worklog do + before(:each) do + stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/2/worklog") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent'=>'Ruby' + }) + .to_return(:status => 200, :body => '{"worklogs":[{"self":"http://localhost:2990/jira/rest/api/2/issue/10002/worklog/10000","id":"10000","comment":"Some epic work."},{"self":"http://localhost:2990/jira/rest/api/2/issue/10002/worklog/10001","id":"10001","comment":"Another worklog."},{"self":"http://localhost:2990/jira/rest/api/2/issue/10002/worklog/10002","id":"10002","comment":"More work."}]}', :headers => {}) + end + with_each_client do |site_url, client| let(:client) { client } diff --git a/spec/jira/resource/filter_spec.rb b/spec/jira/resource/filter_spec.rb index 3949d9f6..d02500b0 100644 --- a/spec/jira/resource/filter_spec.rb +++ b/spec/jira/resource/filter_spec.rb @@ -28,7 +28,7 @@ :owner => jira_user, :jql => '"Git Repository" ~ jira-ruby AND status = Resolved', :viewUrl => 'https://localhost/secure/IssueNavigator.jspa?mode=hide&requestId=42', - :searchUrl => 'https://localhost/rest/api/2/search?jql=%22Git+Repository%22+~+jira-ruby+AND+status+%3D+Resolved', + :searchUrl => 'https://localhost/rest/api/3/search/jql?jql=%22Git+Repository%22+~+jira-ruby+AND+status+%3D+Resolved', :favourite => false, :sharePermissions => [ { @@ -84,9 +84,9 @@ it "returns issues" do expect(filter).to be_present - allow(client).to receive(:options).and_return({ :rest_base_path => 'localhost' }) + allow(client).to receive(:options).and_return({ :rest_base_path => 'localhost', :rest_base_path_v3 => 'localhost' }) expect(client).to receive(:get). - with("localhost/search?jql=#{CGI.escape(filter.jql)}"). + with("localhost/search/jql?jql=#{CGI.escape(filter.jql)}"). and_return(issue_jql_response) issues = filter.issues expect(issues).to be_an(Array) diff --git a/spec/jira/resource/issue_spec.rb b/spec/jira/resource/issue_spec.rb index 3f096aaf..689eada2 100644 --- a/spec/jira/resource/issue_spec.rb +++ b/spec/jira/resource/issue_spec.rb @@ -6,7 +6,7 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: end let(:client) do - client = double(options: {rest_base_path: '/jira/rest/api/2'} ) + client = double(options: {rest_base_path: '/jira/rest/api/2', rest_base_path_v3: '/jira/rest/api/3'}) allow(client).to receive(:Field).and_return(JIRA::Resource::FieldFactory.new(client)) allow(client).to receive(:cache).and_return(OpenStruct.new) client @@ -40,7 +40,7 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: issue = double() allow(response).to receive(:body).and_return('{"issues":[{"id":"1","summary":"Bugs Everywhere"}]}') - expect(client).to receive(:get).with('/jira/rest/api/2/search?expand=transitions.fields'). + expect(client).to receive(:get).with('/jira/rest/api/3/search/jql?expand=transitions.fields'). and_return(response) expect(client).to receive(:Issue).and_return(issue) expect(issue).to receive(:build).with({"id"=>"1","summary"=>"Bugs Everywhere"}) @@ -69,7 +69,7 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: issue = double() allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}') - expect(client).to receive(:get).with('/jira/rest/api/2/search?jql=foo+bar'). + expect(client).to receive(:get).with('/jira/rest/api/3/search/jql?jql=foo+bar'). and_return(response) expect(client).to receive(:Issue).and_return(issue) expect(issue).to receive(:build).with(["key", "foo"]).and_return('') @@ -83,7 +83,7 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}') expect(client).to receive(:get) - .with('/jira/rest/api/2/search?jql=foo+bar&fields=foo,bar') + .with('/jira/rest/api/3/search/jql?jql=foo+bar&fields=foo,bar') .and_return(response) expect(client).to receive(:Issue).and_return(issue) expect(issue).to receive(:build).with(["key", "foo"]).and_return('') @@ -97,7 +97,7 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}') expect(client).to receive(:get) - .with('/jira/rest/api/2/search?jql=foo+bar&startAt=1&maxResults=3') + .with('/jira/rest/api/3/search/jql?jql=foo+bar&startAt=1&maxResults=3') .and_return(response) expect(client).to receive(:Issue).and_return(issue) expect(issue).to receive(:build).with(["key", "foo"]).and_return('') @@ -111,7 +111,7 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}') expect(client).to receive(:get) - .with('/jira/rest/api/2/search?jql=foo+bar&expand=transitions') + .with('/jira/rest/api/3/search/jql?jql=foo+bar&expand=transitions') .and_return(response) expect(client).to receive(:Issue).and_return(issue) expect(issue).to receive(:build).with(["key", "foo"]).and_return('') @@ -125,7 +125,7 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}') expect(client).to receive(:get) - .with('/jira/rest/api/2/search?jql=foo+bar&expand=transitions') + .with('/jira/rest/api/3/search/jql?jql=foo+bar&expand=transitions') .and_return(response) expect(client).to receive(:Issue).and_return(issue) expect(issue).to receive(:build).with(["key", "foo"]).and_return('') @@ -209,4 +209,16 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: expect(subject.worklogs.length).to eq(2) end end + + describe "GET /rest/api/3/search/jql" do + before(:each) do + stub_request(:get, "http://foo:bar@localhost:2990/rest/api/3/search/jql?jql=PROJECT%20=%20'SAMPLEPROJECT'") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent'=>'Ruby' + }) + .to_return(status: 200, body: get_mock_response('issue.json'), headers: {}) + end + end end diff --git a/spec/jira/resource/project_spec.rb b/spec/jira/resource/project_spec.rb index a0720028..8e4fa8f7 100644 --- a/spec/jira/resource/project_spec.rb +++ b/spec/jira/resource/project_spec.rb @@ -42,7 +42,7 @@ issue_factory = double("issue factory") expect(client).to receive(:get) - .with('/jira/rest/api/2/search?jql=project%3D%22test%22') + .with('/jira/rest/api/3/search/jql?jql=project%3D%22test%22') .and_return(response) expect(client).to receive(:Issue).and_return(issue_factory) expect(issue_factory).to receive(:build) @@ -58,7 +58,7 @@ issue_factory = double("issue factory") expect(client).to receive(:get) - .with('/jira/rest/api/2/search?jql=project%3D%22test%22&expand=changelog&startAt=1&maxResults=100') + .with('/jira/rest/api/3/search/jql?jql=project%3D%22test%22&expand=changelog&startAt=1&maxResults=100') .and_return(response) expect(client).to receive(:Issue).and_return(issue_factory) expect(issue_factory).to receive(:build) @@ -67,4 +67,14 @@ end end end + + before(:each) do + stub_request(:get, "http://foo:bar@localhost:2990/rest/api/3/search/jql?jql=PROJECT%20=%20'SAMPLEPROJECT'") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent'=>'Ruby' + }) + .to_return(status: 200, body: get_mock_response('issue.json'), headers: {}) + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 45402031..0604a64e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,46 @@ +RSpec.configure do |config| + config.before(:each) do + stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/2/field") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent'=>'Ruby' + }) + .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 => {}) + stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/2/project") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent'=>'Ruby' + }) + .to_return(:status => 200, :body => '', :headers => {}) + + stub_request(:get, "http://foo:bar@localhost:2990/rest/api/3/search/jql?jql=project=%22SAMPLEPROJECT%22") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent'=>'Ruby' + }) + .to_return(:status => 200, :body => '{ "issues": [ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} ] }', :headers => {}) + + stub_request(:get, "http://localhost:2990/rest/api/3/search/jql?jql=project=%22SAMPLEPROJECT%22") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'Authorization'=>/OAuth .*/, + 'User-Agent'=>/OAuth gem.*/ + }) + .to_return(:status => 200, :body => '{ "issues": [ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} ] }', :headers => {}) + + stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/2/comment") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent'=>'Ruby' + }) + .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 => {}) + end +end $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'active_support/core_ext/hash' require 'rubygems' diff --git a/spec/support/shared_examples/integration.rb b/spec/support/shared_examples/integration.rb index 7d7ac94e..aa2ecdc3 100644 --- a/spec/support/shared_examples/integration.rb +++ b/spec/support/shared_examples/integration.rb @@ -70,8 +70,8 @@ def build_receiver shared_examples "a resource with a collection GET endpoint" do it "should get the collection" do - stub_request(:get, site_url + described_class.collection_path(client)). - to_return(:status => 200, :body => get_mock_from_path(:get)) + stub_request(:get, described_class.collection_path(client)). + to_return(:status => 200, :body => get_mock_from_path(:get)) collection = build_receiver.all expect(collection.length).to eq(expected_collection_length) From 8920b0b93ffcbf6bf76dd1229e3f2b632007eb3b Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Wed, 30 Jul 2025 12:26:04 +0530 Subject: [PATCH 05/21] test fix --- spec/integration/issuetype_spec.rb | 10 ++++++++++ spec/jira/resource/project_spec.rb | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/spec/integration/issuetype_spec.rb b/spec/integration/issuetype_spec.rb index 966c3f8b..7af19373 100644 --- a/spec/integration/issuetype_spec.rb +++ b/spec/integration/issuetype_spec.rb @@ -18,6 +18,16 @@ let(:expected_collection_length) { 5 } + before(:each) do + stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/2/issuetype") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent'=>'Ruby' + }) + .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 => {}) + end + it_should_behave_like "a resource" it_should_behave_like "a resource with a collection GET endpoint" it_should_behave_like "a resource with a singular GET endpoint" diff --git a/spec/jira/resource/project_spec.rb b/spec/jira/resource/project_spec.rb index 8e4fa8f7..ecbb73ef 100644 --- a/spec/jira/resource/project_spec.rb +++ b/spec/jira/resource/project_spec.rb @@ -3,7 +3,8 @@ describe JIRA::Resource::Project do let(:client) { double("client", :options => { - :rest_base_path => '/jira/rest/api/2' + :rest_base_path => '/jira/rest/api/2', + :rest_base_path_v3 => '/jira/rest/api/3' }) } From 0ac325816a76123378dab2fd742119724e66682b Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Wed, 30 Jul 2025 12:40:05 +0530 Subject: [PATCH 06/21] add nextPageToken in search --- lib/jira/resource/issue.rb | 2 +- spec/jira/resource/issue_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jira/resource/issue.rb b/lib/jira/resource/issue.rb index 36ca58a2..32c9115d 100644 --- a/lib/jira/resource/issue.rb +++ b/lib/jira/resource/issue.rb @@ -59,7 +59,7 @@ def self.jql(client, jql, options = {fields: nil, start_at: nil, max_results: ni url = client.options[:rest_base_path_v3] + "/search/jql?jql=" + CGI.escape(jql) url << "&fields=#{options[:fields].map{ |value| CGI.escape(client.Field.name_to_id(value)) }.join(',')}" if options[:fields] - url << "&startAt=#{CGI.escape(options[:start_at].to_s)}" if options[:start_at] + url << "&nextPageToken=#{CGI.escape(options[:start_at].to_s)}" if options[:start_at] url << "&maxResults=#{CGI.escape(options[:max_results].to_s)}" if options[:max_results] if options[:expand] diff --git a/spec/jira/resource/issue_spec.rb b/spec/jira/resource/issue_spec.rb index 689eada2..934adf11 100644 --- a/spec/jira/resource/issue_spec.rb +++ b/spec/jira/resource/issue_spec.rb @@ -97,7 +97,7 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}') expect(client).to receive(:get) - .with('/jira/rest/api/3/search/jql?jql=foo+bar&startAt=1&maxResults=3') + .with('/jira/rest/api/3/search/jql?jql=foo+bar&nextPageToken=1&maxResults=3') .and_return(response) expect(client).to receive(:Issue).and_return(issue) expect(issue).to receive(:build).with(["key", "foo"]).and_return('') From 0db823eb4e4e35d3aa9ac1d3dede4517a67dbba5 Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Wed, 30 Jul 2025 12:56:34 +0530 Subject: [PATCH 07/21] clean up --- spec/integration/comment_spec.rb | 10 +++++++++- spec/integration/field_spec.rb | 10 +++++++++- spec/spec_helper.rb | 23 ----------------------- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/spec/integration/comment_spec.rb b/spec/integration/comment_spec.rb index 83978a5f..e8f8ca2a 100644 --- a/spec/integration/comment_spec.rb +++ b/spec/integration/comment_spec.rb @@ -42,7 +42,15 @@ let(:expected_attributes_from_put) { { "id" => "10000", "body" => "new body" } } - + before(:each) do + stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/2/comment") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent'=>'Ruby' + }) + .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 => {}) + end it_should_behave_like "a resource" it_should_behave_like "a resource with a collection GET endpoint" it_should_behave_like "a resource with a singular GET endpoint" diff --git a/spec/integration/field_spec.rb b/spec/integration/field_spec.rb index 4c2ed59a..97211632 100644 --- a/spec/integration/field_spec.rb +++ b/spec/integration/field_spec.rb @@ -26,7 +26,15 @@ end let(:expected_collection_length) { 2 } - + before(:each) do + stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/2/field") + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent'=>'Ruby' + }) + .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 => {}) + end it_should_behave_like "a resource" it_should_behave_like "a resource with a collection GET endpoint" it_should_behave_like "a resource with a singular GET endpoint" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0604a64e..8398fe0f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,20 +1,5 @@ RSpec.configure do |config| config.before(:each) do - stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/2/field") - .with(headers: { - 'Accept'=>'application/json', - 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', - 'User-Agent'=>'Ruby' - }) - .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 => {}) - stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/2/project") - .with(headers: { - 'Accept'=>'application/json', - 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', - 'User-Agent'=>'Ruby' - }) - .to_return(:status => 200, :body => '', :headers => {}) - stub_request(:get, "http://foo:bar@localhost:2990/rest/api/3/search/jql?jql=project=%22SAMPLEPROJECT%22") .with(headers: { 'Accept'=>'application/json', @@ -31,14 +16,6 @@ 'User-Agent'=>/OAuth gem.*/ }) .to_return(:status => 200, :body => '{ "issues": [ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} ] }', :headers => {}) - - stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/2/comment") - .with(headers: { - 'Accept'=>'application/json', - 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', - 'User-Agent'=>'Ruby' - }) - .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 => {}) end end $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) From f2d71b0c0835901da492f9c2a4cc3dc859a71cd0 Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Wed, 30 Jul 2025 14:01:51 +0530 Subject: [PATCH 08/21] clean up --- lib/jira/client.rb | 1 + spec/integration/issue_spec.rb | 28 +++++++--------------------- spec/integration/project_spec.rb | 2 +- spec/spec_helper.rb | 4 ++-- 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/lib/jira/client.rb b/lib/jira/client.rb index b6003b68..35a21f09 100644 --- a/lib/jira/client.rb +++ b/lib/jira/client.rb @@ -61,6 +61,7 @@ def initialize(options={}) options = DEFAULT_OPTIONS.merge(options) @options = options @options[:rest_base_path] = @options[:context_path] + @options[:rest_base_path] + @options[:rest_base_path_v3] = @options[:context_path] + @options[:rest_base_path_v3] case options[:auth_type] when :oauth diff --git a/spec/integration/issue_spec.rb b/spec/integration/issue_spec.rb index 50409935..c9485449 100644 --- a/spec/integration/issue_spec.rb +++ b/spec/integration/issue_spec.rb @@ -48,31 +48,15 @@ before(:each) do stub_request(:get, site_url + "/jira/rest/api/3/search/jql?expand=transitions.fields"). to_return(:status => 200, :body => get_mock_response('issue.json')) - - stub_request(:get, "http://localhost:2990/rest/api/3/search/jql?expand=transitions.fields") - .with(headers: { - 'Accept'=>'application/json', - 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', - 'Authorization'=>/OAuth .*/, # Use a regex to match any OAuth header - 'User-Agent'=>'OAuth gem v0.5.14' - }) - .to_return(status: 200, body: get_mock_response('issue.json'), headers: {}) - stub_request(:get, "http://foo:bar@localhost:2990/rest/api/3/search/jql?expand=transitions.fields") - .with(headers: { - 'Accept'=>'application/json', - 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', - 'User-Agent'=>'Ruby' - }) - .to_return(status: 200, body: get_mock_response('issue.json'), headers: {}) - end + end it_should_behave_like "a resource with a collection GET endpoint" end it_should_behave_like "a resource with a DELETE endpoint" it_should_behave_like "a resource with a POST endpoint" it_should_behave_like "a resource with a PUT endpoint" it_should_behave_like "a resource with a PUT endpoint that rejects invalid fields" - describe "errors" do + before(:each) do stub_request(:get, site_url + "/jira/rest/api/2/issue/10002"). @@ -103,22 +87,24 @@ "key"=>"SAMPLEPROJECT-13" } } + before(:each) do - stub_request(:get, "http://foo:bar@localhost:2990/rest/api/3/search/jql?jql=PROJECT%20=%20'SAMPLEPROJECT'") + + stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/3/search/jql?jql=PROJECT%20=%20'SAMPLEPROJECT'") .with(headers: { 'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby' }) .to_return(status: 200, body: get_mock_response('issue.json'), headers: {}) - stub_request(:get, "http://localhost:2990/rest/api/3/search/jql?jql=PROJECT%20=%20'SAMPLEPROJECT'") + stub_request(:get, site_url + "/jira/rest/api/3/search/jql?jql=PROJECT%20=%20'SAMPLEPROJECT'") .with(headers: { 'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>/OAuth .*/, # Use a regex to match any OAuth header 'User-Agent'=>'OAuth gem v0.5.14' }) - .to_return(status: 200, body: get_mock_response('issue.json'), headers: {}) + .to_return(status: 200, body: get_mock_response('issue.json'), headers: {}) end it_should_behave_like "a resource with JQL inputs and a collection GET endpoint" end diff --git a/spec/integration/project_spec.rb b/spec/integration/project_spec.rb index cedbd4d7..7befa95e 100644 --- a/spec/integration/project_spec.rb +++ b/spec/integration/project_spec.rb @@ -26,7 +26,7 @@ describe "issues" do it "returns all the issues" do - stub_request(:get, site_url + "/jira/rest/api/2/search?jql=project=\"SAMPLEPROJECT\""). + stub_request(:get, site_url + "/rest/api/3/search?jql=project=\"SAMPLEPROJECT\""). to_return(:status => 200, :body => get_mock_response('project/SAMPLEPROJECT.issues.json')) subject = client.Project.build('key' => key) issues = subject.issues diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8398fe0f..c897d41c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,6 @@ RSpec.configure do |config| config.before(:each) do - stub_request(:get, "http://foo:bar@localhost:2990/rest/api/3/search/jql?jql=project=%22SAMPLEPROJECT%22") + stub_request(:get, "http://foo:bar@localhost:2990/jira/rest/api/3/search/jql?jql=project=%22SAMPLEPROJECT%22") .with(headers: { 'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', @@ -8,7 +8,7 @@ }) .to_return(:status => 200, :body => '{ "issues": [ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} ] }', :headers => {}) - stub_request(:get, "http://localhost:2990/rest/api/3/search/jql?jql=project=%22SAMPLEPROJECT%22") + stub_request(:get, "http://localhost:2990/jira/rest/api/3/search/jql?jql=project=%22SAMPLEPROJECT%22") .with(headers: { 'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', From ae4c7afd98b6aabb593e958bb25526dd2864f488 Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Wed, 30 Jul 2025 15:22:22 +0530 Subject: [PATCH 09/21] test fix --- spec/integration/rapidview_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/integration/rapidview_spec.rb b/spec/integration/rapidview_spec.rb index 54b0647c..e46e815f 100644 --- a/spec/integration/rapidview_spec.rb +++ b/spec/integration/rapidview_spec.rb @@ -45,7 +45,7 @@ :status => 200, :body => get_mock_response('rapidview/SAMPLEPROJECT.issues.json') ) - stub_request(:get, "http://localhost:2990/rest/api/3/search/jql?jql=id%20IN(10000,%2010001)%20AND%20sprint%20IS%20NOT%20EMPTY") + stub_request(:get, "http://localhost:2990/jira/rest/api/3/search/jql?jql=id%20IN(10000,%2010001)%20AND%20sprint%20IS%20NOT%20EMPTY") .with(headers: { 'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', @@ -55,7 +55,7 @@ .to_return(status: 200, body: get_mock_response('rapidview/SAMPLEPROJECT.issues.full.json'), headers: {}) stub_request( :get, - "http://localhost:2990/rest/api/3/search/jql?jql=id%20IN(10001,%2010000)" + "http://localhost:2990/jira/rest/api/3/search/jql?jql=id%20IN(10001,%2010000)" ).with(headers: { 'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', @@ -65,7 +65,7 @@ .to_return(status: 200, body: get_mock_response('rapidview/SAMPLEPROJECT.issues.full.json'), headers: {}) stub_request( :get, - 'http://foo:bar@localhost:2990' + '/rest/api/3/search/jql?jql=id IN(10000, 10001)%20AND%20sprint%20IS%20NOT%20EMPTY' + 'http://foo:bar@localhost:2990' + '/jira/rest/api/3/search/jql?jql=id IN(10000, 10001)%20AND%20sprint%20IS%20NOT%20EMPTY' ).to_return( :status => 200, :body => get_mock_response('rapidview/SAMPLEPROJECT.issues.full.json') @@ -73,7 +73,7 @@ stub_request( :get, - 'http://foo:bar@localhost:2990' + '/rest/api/3/search/jql?jql=id IN(10001, 10000)' + 'http://foo:bar@localhost:2990' + '/jira/rest/api/3/search/jql?jql=id IN(10001, 10000)' ).to_return( :status => 200, :body => get_mock_response('rapidview/SAMPLEPROJECT.issues.full.json') From f7fc66e6c71ab8155ba43d959cd612e682665789 Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Thu, 31 Jul 2025 16:48:34 +0530 Subject: [PATCH 10/21] fixes acc to new apis --- lib/jira/resource/issue.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/jira/resource/issue.rb b/lib/jira/resource/issue.rb index 32c9115d..7e1dea4c 100644 --- a/lib/jira/resource/issue.rb +++ b/lib/jira/resource/issue.rb @@ -55,11 +55,11 @@ def self.all(client) end end - def self.jql(client, jql, options = {fields: nil, start_at: nil, max_results: nil, expand: nil}) + def self.jql(client, jql, options = {fields: nil, nextPageToken: nil, max_results: nil, expand: nil}) url = client.options[:rest_base_path_v3] + "/search/jql?jql=" + CGI.escape(jql) url << "&fields=#{options[:fields].map{ |value| CGI.escape(client.Field.name_to_id(value)) }.join(',')}" if options[:fields] - url << "&nextPageToken=#{CGI.escape(options[:start_at].to_s)}" if options[:start_at] + url << "&nextPageToken=#{CGI.escape(options[:nextPageToken].to_s)}" if options[:nextPageToken] url << "&maxResults=#{CGI.escape(options[:max_results].to_s)}" if options[:max_results] if options[:expand] @@ -69,9 +69,13 @@ def self.jql(client, jql, options = {fields: nil, start_at: nil, max_results: ni response = client.get(url) json = parse_json(response.body) - json['issues'].map do |issue| + result = {} + result['nextPageToken'] = json[:nextPageToken] if json[:nextPageToken] + result['issues'] = json['issues'].map do |issue| client.Issue.build(issue) + end + result end def editmeta From fee31dd3c5f8e38c3aa7e88bef305d95ba8c0b2f Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Thu, 31 Jul 2025 16:51:15 +0530 Subject: [PATCH 11/21] cleanup --- lib/jira/resource/issue.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/jira/resource/issue.rb b/lib/jira/resource/issue.rb index 7e1dea4c..748a3a33 100644 --- a/lib/jira/resource/issue.rb +++ b/lib/jira/resource/issue.rb @@ -55,11 +55,11 @@ def self.all(client) end end - def self.jql(client, jql, options = {fields: nil, nextPageToken: nil, max_results: nil, expand: nil}) + def self.jql(client, jql, options = {fields: nil, next_page_token: nil, max_results: nil, expand: nil}) url = client.options[:rest_base_path_v3] + "/search/jql?jql=" + CGI.escape(jql) url << "&fields=#{options[:fields].map{ |value| CGI.escape(client.Field.name_to_id(value)) }.join(',')}" if options[:fields] - url << "&nextPageToken=#{CGI.escape(options[:nextPageToken].to_s)}" if options[:nextPageToken] + url << "&nextPageToken=#{CGI.escape(options[:next_page_token].to_s)}" if options[:next_page_token] url << "&maxResults=#{CGI.escape(options[:max_results].to_s)}" if options[:max_results] if options[:expand] @@ -70,7 +70,7 @@ def self.jql(client, jql, options = {fields: nil, nextPageToken: nil, max_result response = client.get(url) json = parse_json(response.body) result = {} - result['nextPageToken'] = json[:nextPageToken] if json[:nextPageToken] + result['next_page_token'] = json[:next_page_token] if json[:next_page_token] rescue nil result['issues'] = json['issues'].map do |issue| client.Issue.build(issue) From 66c0a89ff7aee1c8b924222cdd4623ddb9730fb2 Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Thu, 31 Jul 2025 16:52:39 +0530 Subject: [PATCH 12/21] cleanup --- lib/jira/resource/issue.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jira/resource/issue.rb b/lib/jira/resource/issue.rb index 748a3a33..5faf3e4d 100644 --- a/lib/jira/resource/issue.rb +++ b/lib/jira/resource/issue.rb @@ -70,7 +70,7 @@ def self.jql(client, jql, options = {fields: nil, next_page_token: nil, max_resu response = client.get(url) json = parse_json(response.body) result = {} - result['next_page_token'] = json[:next_page_token] if json[:next_page_token] rescue nil + result['next_page_token'] = json['nextPageToken'] if json['nextPageToken'] rescue nil result['issues'] = json['issues'].map do |issue| client.Issue.build(issue) From 645554434f57b419c47038ddb360eab1522430c0 Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Thu, 31 Jul 2025 19:05:42 +0530 Subject: [PATCH 13/21] test fixes --- spec/jira/resource/issue_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/jira/resource/issue_spec.rb b/spec/jira/resource/issue_spec.rb index 934adf11..674a4e22 100644 --- a/spec/jira/resource/issue_spec.rb +++ b/spec/jira/resource/issue_spec.rb @@ -74,7 +74,7 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: expect(client).to receive(:Issue).and_return(issue) expect(issue).to receive(:build).with(["key", "foo"]).and_return('') - expect(JIRA::Resource::Issue.jql(client,'foo bar')).to eq(['']) + expect(JIRA::Resource::Issue.jql(client,'foo bar')).to eq({"issues" => [""]}) end it "should search an issue with a jql query string and fields" do @@ -88,7 +88,7 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: expect(client).to receive(:Issue).and_return(issue) expect(issue).to receive(:build).with(["key", "foo"]).and_return('') - expect(JIRA::Resource::Issue.jql(client, 'foo bar', fields: ['foo','bar'])).to eq(['']) + expect(JIRA::Resource::Issue.jql(client, 'foo bar', fields: ['foo','bar'])).to eq({"issues" => [""]}) end it "should search an issue with a jql query string, start at, and maxResults" do @@ -97,12 +97,12 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}') expect(client).to receive(:get) - .with('/jira/rest/api/3/search/jql?jql=foo+bar&nextPageToken=1&maxResults=3') + .with('/jira/rest/api/3/search/jql?jql=foo+bar&maxResults=3') .and_return(response) expect(client).to receive(:Issue).and_return(issue) expect(issue).to receive(:build).with(["key", "foo"]).and_return('') - expect(JIRA::Resource::Issue.jql(client,'foo bar', start_at: 1, max_results: 3)).to eq(['']) + expect(JIRA::Resource::Issue.jql(client,'foo bar', start_at: 1, max_results: 3)).to eq({"issues" => [""]}) end it "should search an issue with a jql query string and string expand" do @@ -116,7 +116,7 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: expect(client).to receive(:Issue).and_return(issue) expect(issue).to receive(:build).with(["key", "foo"]).and_return('') - expect(JIRA::Resource::Issue.jql(client,'foo bar', expand: 'transitions')).to eq(['']) + expect(JIRA::Resource::Issue.jql(client,'foo bar', expand: 'transitions')).to eq("issues" =>[""]) end it "should search an issue with a jql query string and array expand" do @@ -130,7 +130,7 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: expect(client).to receive(:Issue).and_return(issue) expect(issue).to receive(:build).with(["key", "foo"]).and_return('') - expect(JIRA::Resource::Issue.jql(client,'foo bar', expand: %w(transitions))).to eq(['']) + expect(JIRA::Resource::Issue.jql(client,'foo bar', expand: %w(transitions))).to eq("issues" =>[""]) end it 'should return meta data available for editing an issue' do From 1aece03214ab1cf1f8b261dec702ac010c0c454a Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Thu, 31 Jul 2025 19:14:56 +0530 Subject: [PATCH 14/21] fix filter_spec --- spec/jira/resource/filter_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/jira/resource/filter_spec.rb b/spec/jira/resource/filter_spec.rb index d02500b0..8b368739 100644 --- a/spec/jira/resource/filter_spec.rb +++ b/spec/jira/resource/filter_spec.rb @@ -66,7 +66,7 @@ end let(:jql_attrs) do { - :startAt => 0, + :nextPageToken => 0, :maxResults => 50, :total => 2, :issues => [jql_issue] @@ -89,9 +89,9 @@ with("localhost/search/jql?jql=#{CGI.escape(filter.jql)}"). and_return(issue_jql_response) issues = filter.issues - expect(issues).to be_an(Array) - expect(issues.size).to eql(1) + expect(issues).to be_an(Hash) + expect(issues["issues"].size).to eql(1) expected_issue = client.Issue.build(JSON.parse(jql_issue.to_json)) - expect(issues.first.attrs).to eql(expected_issue.attrs) + expect(issues["issues"].first.attrs).to eql(expected_issue.attrs) end end From b5474ba76542bb09df0f09652361812ddd4c06db Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Thu, 31 Jul 2025 19:24:56 +0530 Subject: [PATCH 15/21] fix rapidview tests --- lib/jira/resource/rapidview.rb | 6 +++--- spec/integration/rapidview_spec.rb | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/jira/resource/rapidview.rb b/lib/jira/resource/rapidview.rb index 6ed1526f..a82f4431 100644 --- a/lib/jira/resource/rapidview.rb +++ b/lib/jira/resource/rapidview.rb @@ -32,9 +32,9 @@ def issues(options = {}) jql = "id IN(#{issue_ids.join(', ')})" # Filtering options - jql << " AND sprint IS NOT EMPTY" unless options[:include_backlog_items] - - parent_issues = client.Issue.jql(jql) + jql << " AND sprint IS NOT EMPTY" unless options[:include_backlog_items] + + parent_issues = client.Issue.jql(jql)["issues"] subtask_ids = parent_issues.map { |t| t.subtasks.map { |sub| sub['id'] } }.flatten parent_and_sub_ids = parent_issues.map(&:id) + subtask_ids diff --git a/spec/integration/rapidview_spec.rb b/spec/integration/rapidview_spec.rb index e46e815f..3fcc3d32 100644 --- a/spec/integration/rapidview_spec.rb +++ b/spec/integration/rapidview_spec.rb @@ -81,9 +81,8 @@ subject = client.RapidView.build('id' => 1) issues = subject.issues - expect(issues.length).to eq(2) - - issues.each do |issue| + expect(issues["issues"].length).to eq(2) + issues["issues"].each do |issue| expect(issue.class).to eq(JIRA::Resource::Issue) expect(issue.expanded?).to be_falsey end From 88e904aab2d64aad118765e9cc77b8881c66a9bd Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Thu, 31 Jul 2025 20:07:41 +0530 Subject: [PATCH 16/21] test fix --- spec/support/shared_examples/integration.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spec/support/shared_examples/integration.rb b/spec/support/shared_examples/integration.rb index aa2ecdc3..1d3e6cc8 100644 --- a/spec/support/shared_examples/integration.rb +++ b/spec/support/shared_examples/integration.rb @@ -86,15 +86,14 @@ def build_receiver stub_request( :get, site_url + - client.options[:rest_base_path] + - '/search?jql=' + + client.options[:rest_base_path_v3] + + '/search/jql?jql=' + CGI.escape(jql_query_string) ).to_return(:status => 200, :body => get_mock_response('issue.json')) collection = build_receiver.jql(jql_query_string) - - expect(collection.length).to eq(expected_collection_length) - expect(collection.first).to have_attributes(expected_attributes) + expect(collection["issues"].length).to eq(expected_collection_length) + expect(collection["issues"].first).to have_attributes(expected_attributes) end end From c16583fb0efcd1e21705f032a28709f98a0b5ec8 Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Thu, 31 Jul 2025 20:11:23 +0530 Subject: [PATCH 17/21] clean up --- lib/jira/resource/rapidview.rb | 2 +- spec/support/shared_examples/integration.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/jira/resource/rapidview.rb b/lib/jira/resource/rapidview.rb index a82f4431..99d9824a 100644 --- a/lib/jira/resource/rapidview.rb +++ b/lib/jira/resource/rapidview.rb @@ -33,7 +33,7 @@ def issues(options = {}) # Filtering options jql << " AND sprint IS NOT EMPTY" unless options[:include_backlog_items] - + parent_issues = client.Issue.jql(jql)["issues"] subtask_ids = parent_issues.map { |t| t.subtasks.map { |sub| sub['id'] } }.flatten diff --git a/spec/support/shared_examples/integration.rb b/spec/support/shared_examples/integration.rb index 1d3e6cc8..b5239915 100644 --- a/spec/support/shared_examples/integration.rb +++ b/spec/support/shared_examples/integration.rb @@ -70,8 +70,8 @@ def build_receiver shared_examples "a resource with a collection GET endpoint" do it "should get the collection" do - stub_request(:get, described_class.collection_path(client)). - to_return(:status => 200, :body => get_mock_from_path(:get)) + stub_request(:get, described_class.collection_path(client)). + to_return(:status => 200, :body => get_mock_from_path(:get)) collection = build_receiver.all expect(collection.length).to eq(expected_collection_length) From a0abbf5f15e53d7b708be1de146c386309fe2971 Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Fri, 1 Aug 2025 15:04:24 +0530 Subject: [PATCH 18/21] support for v2 search --- lib/jira/resource/issue.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/jira/resource/issue.rb b/lib/jira/resource/issue.rb index 5faf3e4d..0ec2c7b7 100644 --- a/lib/jira/resource/issue.rb +++ b/lib/jira/resource/issue.rb @@ -56,7 +56,7 @@ def self.all(client) end def self.jql(client, jql, options = {fields: nil, next_page_token: nil, max_results: nil, expand: nil}) - url = client.options[:rest_base_path_v3] + "/search/jql?jql=" + CGI.escape(jql) + url = options[:url] || client.options[:rest_base_path_v3] + "/search/jql?jql=" + CGI.escape(jql) url << "&fields=#{options[:fields].map{ |value| CGI.escape(client.Field.name_to_id(value)) }.join(',')}" if options[:fields] url << "&nextPageToken=#{CGI.escape(options[:next_page_token].to_s)}" if options[:next_page_token] @@ -66,7 +66,6 @@ def self.jql(client, jql, options = {fields: nil, next_page_token: nil, max_resu options[:expand] = [options[:expand]] if options[:expand].is_a?(String) url << "&expand=#{options[:expand].to_a.map{ |value| CGI.escape(value.to_s) }.join(',')}" end - response = client.get(url) json = parse_json(response.body) result = {} @@ -78,6 +77,13 @@ def self.jql(client, jql, options = {fields: nil, next_page_token: nil, max_resu result end + def self.jql_v2(client, jql, options = {fields: nil, next_page_token: nil, max_results: nil, expand: nil}) + url = client.options[:rest_base_path] + "/search/jql?jql=" + CGI.escape(jql) + options[url] = url + self.jql(client, url, jql, options) + end + + def editmeta editmeta_url = client.options[:rest_base_path] + "/#{self.class.endpoint_name}/#{key}/editmeta" From a8c87dcfc22bd1d2137f913db621f19bac5572d4 Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Fri, 1 Aug 2025 17:10:11 +0530 Subject: [PATCH 19/21] tests added --- lib/jira/resource/issue.rb | 11 ++--- spec/jira/resource/issue_spec.rb | 72 ++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 5 deletions(-) diff --git a/lib/jira/resource/issue.rb b/lib/jira/resource/issue.rb index 0ec2c7b7..c9969ffe 100644 --- a/lib/jira/resource/issue.rb +++ b/lib/jira/resource/issue.rb @@ -56,8 +56,9 @@ def self.all(client) end def self.jql(client, jql, options = {fields: nil, next_page_token: nil, max_results: nil, expand: nil}) - url = options[:url] || client.options[:rest_base_path_v3] + "/search/jql?jql=" + CGI.escape(jql) - + url = options[:url] || client.options[:rest_base_path_v3] + url += "/search/jql?jql=" + CGI.escape(jql) + url << "&fields=#{options[:fields].map{ |value| CGI.escape(client.Field.name_to_id(value)) }.join(',')}" if options[:fields] url << "&nextPageToken=#{CGI.escape(options[:next_page_token].to_s)}" if options[:next_page_token] url << "&maxResults=#{CGI.escape(options[:max_results].to_s)}" if options[:max_results] @@ -78,9 +79,9 @@ def self.jql(client, jql, options = {fields: nil, next_page_token: nil, max_resu end def self.jql_v2(client, jql, options = {fields: nil, next_page_token: nil, max_results: nil, expand: nil}) - url = client.options[:rest_base_path] + "/search/jql?jql=" + CGI.escape(jql) - options[url] = url - self.jql(client, url, jql, options) + url = client.options[:rest_base_path] + options[:url] = url + self.jql(client, jql, options) end diff --git a/spec/jira/resource/issue_spec.rb b/spec/jira/resource/issue_spec.rb index 674a4e22..6d31ebff 100644 --- a/spec/jira/resource/issue_spec.rb +++ b/spec/jira/resource/issue_spec.rb @@ -133,6 +133,77 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: expect(JIRA::Resource::Issue.jql(client,'foo bar', expand: %w(transitions))).to eq("issues" =>[""]) end + it "should search an issue with a jql query string for v2 version" do + response = double() + issue = double() + + allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}') + expect(client).to receive(:get).with('/jira/rest/api/2/search/jql?jql=foo+bar'). + and_return(response) + expect(client).to receive(:Issue).and_return(issue) + expect(issue).to receive(:build).with(["key", "foo"]).and_return('') + + expect(JIRA::Resource::Issue.jql_v2(client,'foo bar')).to eq({"issues" => [""]}) + end + + it "should search an issue with a jql query string and fields for v2 version" do + response = double() + issue = double() + + allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}') + expect(client).to receive(:get) + .with('/jira/rest/api/2/search/jql?jql=foo+bar&fields=foo,bar') + .and_return(response) + expect(client).to receive(:Issue).and_return(issue) + expect(issue).to receive(:build).with(["key", "foo"]).and_return('') + + expect(JIRA::Resource::Issue.jql_v2(client, 'foo bar', fields: ['foo','bar'])).to eq({"issues" => [""]}) + end + + it "should search an issue with a jql query string, start at, and maxResults for v2 version" do + response = double() + issue = double() + + allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}') + expect(client).to receive(:get) + .with('/jira/rest/api/2/search/jql?jql=foo+bar&maxResults=3') + .and_return(response) + expect(client).to receive(:Issue).and_return(issue) + expect(issue).to receive(:build).with(["key", "foo"]).and_return('') + + expect(JIRA::Resource::Issue.jql_v2(client,'foo bar', start_at: 1, max_results: 3)).to eq({"issues" => [""]}) + end + + it "should search an issue with a jql query string and string expand for v2 version" do + response = double() + issue = double() + + allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}') + expect(client).to receive(:get) + .with('/jira/rest/api/2/search/jql?jql=foo+bar&expand=transitions') + .and_return(response) + expect(client).to receive(:Issue).and_return(issue) + expect(issue).to receive(:build).with(["key", "foo"]).and_return('') + + expect(JIRA::Resource::Issue.jql_v2(client,'foo bar', expand: 'transitions')).to eq("issues" =>[""]) + end + + it "should search an issue with a jql query string and array expand for v2 version" do + response = double() + issue = double() + + allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}') + expect(client).to receive(:get) + .with('/jira/rest/api/2/search/jql?jql=foo+bar&expand=transitions') + .and_return(response) + expect(client).to receive(:Issue).and_return(issue) + expect(issue).to receive(:build).with(["key", "foo"]).and_return('') + + expect(JIRA::Resource::Issue.jql_v2(client,'foo bar', expand: %w(transitions))).to eq("issues" =>[""]) + end + + + it 'should return meta data available for editing an issue' do subject = JIRA::Resource::Issue.new(client, :attrs => {'fields' => {'key' =>'TST=123'}}) response = double() @@ -222,3 +293,4 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: end end end + From 5a24373124f9723c49eec8341c2dac61b7f23c6f Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Tue, 5 Aug 2025 20:56:02 +0530 Subject: [PATCH 20/21] keep v2 version for on-prem clients --- lib/jira/resource/issue.rb | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/lib/jira/resource/issue.rb b/lib/jira/resource/issue.rb index c9969ffe..ef2b73a5 100644 --- a/lib/jira/resource/issue.rb +++ b/lib/jira/resource/issue.rb @@ -55,10 +55,29 @@ def self.all(client) end end + + def self.jql_v2(client, jql, options = {fields: nil, start_at: nil, max_results: nil, expand: nil}) + url = client.options[:rest_base_path] + "/search?jql=" + CGI.escape(jql) + + url << "&fields=#{options[:fields].map{ |value| CGI.escape(client.Field.name_to_id(value)) }.join(',')}" if options[:fields] + url << "&startAt=#{CGI.escape(options[:start_at].to_s)}" if options[:start_at] + url << "&maxResults=#{CGI.escape(options[:max_results].to_s)}" if options[:max_results] + + if options[:expand] + options[:expand] = [options[:expand]] if options[:expand].is_a?(String) + url << "&expand=#{options[:expand].to_a.map{ |value| CGI.escape(value.to_s) }.join(',')}" + end + + response = client.get(url) + json = parse_json(response.body) + json['issues'].map do |issue| + client.Issue.build(issue) + end + end + def self.jql(client, jql, options = {fields: nil, next_page_token: nil, max_results: nil, expand: nil}) - url = options[:url] || client.options[:rest_base_path_v3] - url += "/search/jql?jql=" + CGI.escape(jql) - + url = client.options[:rest_base_path_v3] + "/search/jql?jql=" + CGI.escape(jql) + url << "&fields=#{options[:fields].map{ |value| CGI.escape(client.Field.name_to_id(value)) }.join(',')}" if options[:fields] url << "&nextPageToken=#{CGI.escape(options[:next_page_token].to_s)}" if options[:next_page_token] url << "&maxResults=#{CGI.escape(options[:max_results].to_s)}" if options[:max_results] @@ -67,6 +86,7 @@ def self.jql(client, jql, options = {fields: nil, next_page_token: nil, max_resu options[:expand] = [options[:expand]] if options[:expand].is_a?(String) url << "&expand=#{options[:expand].to_a.map{ |value| CGI.escape(value.to_s) }.join(',')}" end + response = client.get(url) json = parse_json(response.body) result = {} @@ -78,13 +98,6 @@ def self.jql(client, jql, options = {fields: nil, next_page_token: nil, max_resu result end - def self.jql_v2(client, jql, options = {fields: nil, next_page_token: nil, max_results: nil, expand: nil}) - url = client.options[:rest_base_path] - options[:url] = url - self.jql(client, jql, options) - end - - def editmeta editmeta_url = client.options[:rest_base_path] + "/#{self.class.endpoint_name}/#{key}/editmeta" From a7eea863a4aad830190e12b6d500b58381e48e59 Mon Sep 17 00:00:00 2001 From: aditiguptakantata Date: Tue, 5 Aug 2025 22:09:00 +0530 Subject: [PATCH 21/21] test cases fixed --- spec/jira/resource/issue_spec.rb | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/spec/jira/resource/issue_spec.rb b/spec/jira/resource/issue_spec.rb index 6d31ebff..a801af73 100644 --- a/spec/jira/resource/issue_spec.rb +++ b/spec/jira/resource/issue_spec.rb @@ -138,12 +138,12 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: issue = double() allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}') - expect(client).to receive(:get).with('/jira/rest/api/2/search/jql?jql=foo+bar'). + expect(client).to receive(:get).with('/jira/rest/api/2/search?jql=foo+bar'). and_return(response) expect(client).to receive(:Issue).and_return(issue) expect(issue).to receive(:build).with(["key", "foo"]).and_return('') - expect(JIRA::Resource::Issue.jql_v2(client,'foo bar')).to eq({"issues" => [""]}) + expect(JIRA::Resource::Issue.jql_v2(client,'foo bar')).to eq(['']) end it "should search an issue with a jql query string and fields for v2 version" do @@ -152,12 +152,12 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}') expect(client).to receive(:get) - .with('/jira/rest/api/2/search/jql?jql=foo+bar&fields=foo,bar') + .with('/jira/rest/api/2/search?jql=foo+bar&fields=foo,bar') .and_return(response) expect(client).to receive(:Issue).and_return(issue) expect(issue).to receive(:build).with(["key", "foo"]).and_return('') - expect(JIRA::Resource::Issue.jql_v2(client, 'foo bar', fields: ['foo','bar'])).to eq({"issues" => [""]}) + expect(JIRA::Resource::Issue.jql_v2(client, 'foo bar', fields: ['foo','bar'])).to eq(['']) end it "should search an issue with a jql query string, start at, and maxResults for v2 version" do @@ -166,12 +166,12 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}') expect(client).to receive(:get) - .with('/jira/rest/api/2/search/jql?jql=foo+bar&maxResults=3') + .with('/jira/rest/api/2/search?jql=foo+bar&startAt=1&maxResults=3') .and_return(response) expect(client).to receive(:Issue).and_return(issue) expect(issue).to receive(:build).with(["key", "foo"]).and_return('') - expect(JIRA::Resource::Issue.jql_v2(client,'foo bar', start_at: 1, max_results: 3)).to eq({"issues" => [""]}) + expect(JIRA::Resource::Issue.jql_v2(client,'foo bar', start_at: 1, max_results: 3)).to eq(['']) end it "should search an issue with a jql query string and string expand for v2 version" do @@ -180,12 +180,12 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}') expect(client).to receive(:get) - .with('/jira/rest/api/2/search/jql?jql=foo+bar&expand=transitions') + .with('/jira/rest/api/2/search?jql=foo+bar&expand=transitions') .and_return(response) expect(client).to receive(:Issue).and_return(issue) expect(issue).to receive(:build).with(["key", "foo"]).and_return('') - expect(JIRA::Resource::Issue.jql_v2(client,'foo bar', expand: 'transitions')).to eq("issues" =>[""]) + expect(JIRA::Resource::Issue.jql_v2(client,'foo bar', expand: 'transitions')).to eq(['']) end it "should search an issue with a jql query string and array expand for v2 version" do @@ -194,16 +194,14 @@ class JIRAResourceDelegation < SimpleDelegator # :nodoc: allow(response).to receive(:body).and_return('{"issues": {"key":"foo"}}') expect(client).to receive(:get) - .with('/jira/rest/api/2/search/jql?jql=foo+bar&expand=transitions') + .with('/jira/rest/api/2/search?jql=foo+bar&expand=transitions') .and_return(response) expect(client).to receive(:Issue).and_return(issue) expect(issue).to receive(:build).with(["key", "foo"]).and_return('') - expect(JIRA::Resource::Issue.jql_v2(client,'foo bar', expand: %w(transitions))).to eq("issues" =>[""]) + expect(JIRA::Resource::Issue.jql_v2(client,'foo bar', expand: %w(transitions))).to eq(['']) end - - it 'should return meta data available for editing an issue' do subject = JIRA::Resource::Issue.new(client, :attrs => {'fields' => {'key' =>'TST=123'}}) response = double()