From c24007214ce15a10f221ee81a180675ad522b8c2 Mon Sep 17 00:00:00 2001 From: Theotata <111467831+Theotata@users.noreply.github.com> Date: Thu, 31 Jul 2025 20:18:00 -0400 Subject: [PATCH 1/2] Revert "IE 1122 update deprecated jira apis (#20)" This reverts commit f07e374d8673b86e6ab152c7aa03e935a933f6bc. --- .github/workflows/rspec.yaml | 4 +-- README.rdoc | 1 - lib/jira/client.rb | 2 -- lib/jira/resource/issue.rb | 14 +++----- lib/jira/resource/project.rb | 2 +- lib/jira/resource/rapidview.rb | 4 +-- spec/integration/comment_spec.rb | 10 +----- spec/integration/field_spec.rb | 10 +----- spec/integration/issue_spec.rb | 23 ++----------- spec/integration/issuelinktype_spec.rb | 14 -------- spec/integration/issuetype_spec.rb | 10 ------ spec/integration/priority_spec.rb | 10 ------ spec/integration/project_spec.rb | 12 +------ spec/integration/rapidview_spec.rb | 29 ++++------------- spec/integration/status_spec.rb | 10 ------ spec/integration/worklog_spec.rb | 10 ------ spec/jira/resource/filter_spec.rb | 14 ++++---- spec/jira/resource/issue_spec.rb | 36 +++++++-------------- spec/jira/resource/project_spec.rb | 17 ++-------- spec/spec_helper.rb | 20 ------------ spec/support/shared_examples/integration.rb | 13 ++++---- 21 files changed, 50 insertions(+), 215 deletions(-) diff --git a/.github/workflows/rspec.yaml b/.github/workflows/rspec.yaml index 6235fdda..6a2f1ee7 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@v4 + - uses: actions/checkout@v1 - name: Gem cache id: cache-bundle - uses: actions/cache@v4 + uses: actions/cache@v1 with: path: vendor/bundle key: bundle-${{ hashFiles('**/Gemfile.lock') }} diff --git a/README.rdoc b/README.rdoc index 9f4f4ae0..ed10f83f 100644 --- a/README.rdoc +++ b/README.rdoc @@ -235,7 +235,6 @@ 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" } diff --git a/lib/jira/client.rb b/lib/jira/client.rb index 35a21f09..0ce3d5d7 100644 --- a/lib/jira/client.rb +++ b/lib/jira/client.rb @@ -50,7 +50,6 @@ 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, @@ -61,7 +60,6 @@ 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/lib/jira/resource/issue.rb b/lib/jira/resource/issue.rb index 5faf3e4d..96d75204 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_v3] + '/search/jql?expand=transitions.fields' + url = client.options[:rest_base_path] + "/search?expand=transitions.fields" response = client.get(url) json = parse_json(response.body) json['issues'].map do |issue| @@ -55,11 +55,11 @@ def self.all(client) end 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) + 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 << "&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 << "&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] @@ -69,13 +69,9 @@ 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['nextPageToken'] if json['nextPageToken'] rescue nil - result['issues'] = json['issues'].map do |issue| + json['issues'].map do |issue| client.Issue.build(issue) - end - result end def editmeta diff --git a/lib/jira/resource/project.rb b/lib/jira/resource/project.rb index 3fa0c9bf..8248db16 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_v3] + "/search/jql" + search_url = client.options[:rest_base_path] + '/search' 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)) diff --git a/lib/jira/resource/rapidview.rb b/lib/jira/resource/rapidview.rb index 99d9824a..6ed1526f 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] + jql << " AND sprint IS NOT EMPTY" unless options[:include_backlog_items] - parent_issues = client.Issue.jql(jql)["issues"] + parent_issues = client.Issue.jql(jql) 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/comment_spec.rb b/spec/integration/comment_spec.rb index e8f8ca2a..83978a5f 100644 --- a/spec/integration/comment_spec.rb +++ b/spec/integration/comment_spec.rb @@ -42,15 +42,7 @@ 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 97211632..4c2ed59a 100644 --- a/spec/integration/field_spec.rb +++ b/spec/integration/field_spec.rb @@ -26,15 +26,7 @@ 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/integration/issue_spec.rb b/spec/integration/issue_spec.rb index c9485449..39cc0c7d 100644 --- a/spec/integration/issue_spec.rb +++ b/spec/integration/issue_spec.rb @@ -46,7 +46,7 @@ } } before(:each) do - stub_request(:get, site_url + "/jira/rest/api/3/search/jql?expand=transitions.fields"). + stub_request(:get, site_url + "/jira/rest/api/2/search?expand=transitions.fields"). to_return(:status => 200, :body => get_mock_response('issue.json')) end it_should_behave_like "a resource with a collection GET endpoint" @@ -55,8 +55,8 @@ 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"). @@ -87,25 +87,6 @@ "key"=>"SAMPLEPROJECT-13" } } - - before(:each) do - - 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, 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: {}) - 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 4f914b4b..dedff7f2 100644 --- a/spec/integration/issuelinktype_spec.rb +++ b/spec/integration/issuelinktype_spec.rb @@ -2,20 +2,6 @@ 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/issuetype_spec.rb b/spec/integration/issuetype_spec.rb index 7af19373..966c3f8b 100644 --- a/spec/integration/issuetype_spec.rb +++ b/spec/integration/issuetype_spec.rb @@ -18,16 +18,6 @@ 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/integration/priority_spec.rb b/spec/integration/priority_spec.rb index bc528bdd..d96a068f 100644 --- a/spec/integration/priority_spec.rb +++ b/spec/integration/priority_spec.rb @@ -2,16 +2,6 @@ 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 7befa95e..72337e54 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 + "/rest/api/3/search?jql=project=\"SAMPLEPROJECT\""). + stub_request(:get, site_url + "/jira/rest/api/2/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 @@ -52,15 +52,5 @@ 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 3fcc3d32..67b3c0e4 100644 --- a/spec/integration/rapidview_spec.rb +++ b/spec/integration/rapidview_spec.rb @@ -30,7 +30,6 @@ 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 @@ -45,27 +44,10 @@ :status => 200, :body => get_mock_response('rapidview/SAMPLEPROJECT.issues.json') ) - 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', - '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/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', - '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://foo:bar@localhost:2990' + '/jira/rest/api/3/search/jql?jql=id IN(10000, 10001)%20AND%20sprint%20IS%20NOT%20EMPTY' + site_url + '/jira/rest/api/2/search?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 +55,7 @@ stub_request( :get, - 'http://foo:bar@localhost:2990' + '/jira/rest/api/3/search/jql?jql=id IN(10001, 10000)' + site_url + '/jira/rest/api/2/search?jql=id IN(10001, 10000)' ).to_return( :status => 200, :body => get_mock_response('rapidview/SAMPLEPROJECT.issues.full.json') @@ -81,8 +63,9 @@ subject = client.RapidView.build('id' => 1) issues = subject.issues - expect(issues["issues"].length).to eq(2) - issues["issues"].each do |issue| + expect(issues.length).to eq(2) + + issues.each do |issue| expect(issue.class).to eq(JIRA::Resource::Issue) expect(issue.expanded?).to be_falsey end diff --git a/spec/integration/status_spec.rb b/spec/integration/status_spec.rb index b5f00fb9..ec2662a2 100644 --- a/spec/integration/status_spec.rb +++ b/spec/integration/status_spec.rb @@ -2,16 +2,6 @@ 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 5164d9fa..944869a3 100644 --- a/spec/integration/worklog_spec.rb +++ b/spec/integration/worklog_spec.rb @@ -2,16 +2,6 @@ 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 8b368739..3949d9f6 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/3/search/jql?jql=%22Git+Repository%22+~+jira-ruby+AND+status+%3D+Resolved', + :searchUrl => 'https://localhost/rest/api/2/search?jql=%22Git+Repository%22+~+jira-ruby+AND+status+%3D+Resolved', :favourite => false, :sharePermissions => [ { @@ -66,7 +66,7 @@ end let(:jql_attrs) do { - :nextPageToken => 0, + :startAt => 0, :maxResults => 50, :total => 2, :issues => [jql_issue] @@ -84,14 +84,14 @@ it "returns issues" do expect(filter).to be_present - allow(client).to receive(:options).and_return({ :rest_base_path => 'localhost', :rest_base_path_v3 => 'localhost' }) + allow(client).to receive(:options).and_return({ :rest_base_path => 'localhost' }) expect(client).to receive(:get). - with("localhost/search/jql?jql=#{CGI.escape(filter.jql)}"). + with("localhost/search?jql=#{CGI.escape(filter.jql)}"). and_return(issue_jql_response) issues = filter.issues - expect(issues).to be_an(Hash) - expect(issues["issues"].size).to eql(1) + expect(issues).to be_an(Array) + expect(issues.size).to eql(1) expected_issue = client.Issue.build(JSON.parse(jql_issue.to_json)) - expect(issues["issues"].first.attrs).to eql(expected_issue.attrs) + expect(issues.first.attrs).to eql(expected_issue.attrs) end end diff --git a/spec/jira/resource/issue_spec.rb b/spec/jira/resource/issue_spec.rb index 674a4e22..3f096aaf 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', rest_base_path_v3: '/jira/rest/api/3'}) + client = double(options: {rest_base_path: '/jira/rest/api/2'} ) 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/3/search/jql?expand=transitions.fields'). + expect(client).to receive(:get).with('/jira/rest/api/2/search?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,12 +69,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/3/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(client,'foo bar')).to eq({"issues" => [""]}) + expect(JIRA::Resource::Issue.jql(client,'foo bar')).to eq(['']) end it "should search an issue with a jql query string and fields" do @@ -83,12 +83,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&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(client, 'foo bar', fields: ['foo','bar'])).to eq({"issues" => [""]}) + expect(JIRA::Resource::Issue.jql(client, 'foo bar', fields: ['foo','bar'])).to eq(['']) 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&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(client,'foo bar', start_at: 1, max_results: 3)).to eq({"issues" => [""]}) + expect(JIRA::Resource::Issue.jql(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" do @@ -111,12 +111,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&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(client,'foo bar', expand: 'transitions')).to eq("issues" =>[""]) + expect(JIRA::Resource::Issue.jql(client,'foo bar', expand: 'transitions')).to eq(['']) end it "should search an issue with a jql query string and array expand" do @@ -125,12 +125,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&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(client,'foo bar', expand: %w(transitions))).to eq("issues" =>[""]) + expect(JIRA::Resource::Issue.jql(client,'foo bar', expand: %w(transitions))).to eq(['']) end it 'should return meta data available for editing an issue' do @@ -209,16 +209,4 @@ 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 ecbb73ef..a0720028 100644 --- a/spec/jira/resource/project_spec.rb +++ b/spec/jira/resource/project_spec.rb @@ -3,8 +3,7 @@ describe JIRA::Resource::Project do let(:client) { double("client", :options => { - :rest_base_path => '/jira/rest/api/2', - :rest_base_path_v3 => '/jira/rest/api/3' + :rest_base_path => '/jira/rest/api/2' }) } @@ -43,7 +42,7 @@ issue_factory = double("issue factory") expect(client).to receive(:get) - .with('/jira/rest/api/3/search/jql?jql=project%3D%22test%22') + .with('/jira/rest/api/2/search?jql=project%3D%22test%22') .and_return(response) expect(client).to receive(:Issue).and_return(issue_factory) expect(issue_factory).to receive(:build) @@ -59,7 +58,7 @@ issue_factory = double("issue factory") expect(client).to receive(:get) - .with('/jira/rest/api/3/search/jql?jql=project%3D%22test%22&expand=changelog&startAt=1&maxResults=100') + .with('/jira/rest/api/2/search?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) @@ -68,14 +67,4 @@ 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 c897d41c..45402031 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,23 +1,3 @@ -RSpec.configure do |config| - config.before(:each) do - 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', - 'User-Agent'=>'Ruby' - }) - .to_return(:status => 200, :body => '{ "issues": [ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} ] }', :headers => {}) - - 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', - 'Authorization'=>/OAuth .*/, - 'User-Agent'=>/OAuth gem.*/ - }) - .to_return(:status => 200, :body => '{ "issues": [ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} ] }', :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 b5239915..7d7ac94e 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, site_url + 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) @@ -86,14 +86,15 @@ def build_receiver stub_request( :get, site_url + - client.options[:rest_base_path_v3] + - '/search/jql?jql=' + + client.options[:rest_base_path] + + '/search?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["issues"].length).to eq(expected_collection_length) - expect(collection["issues"].first).to have_attributes(expected_attributes) + + expect(collection.length).to eq(expected_collection_length) + expect(collection.first).to have_attributes(expected_attributes) end end From e21968881a47a9c72e6e5f45050c99b1387adda9 Mon Sep 17 00:00:00 2001 From: Theotata <111467831+Theotata@users.noreply.github.com> Date: Thu, 31 Jul 2025 20:23:58 -0400 Subject: [PATCH 2/2] fix: restore github actions to v4 --- .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') }}