Fix JIRA not working when a trailing slash is included
Leaving a trailing slash in the context option causes the jira-ruby gem to add an extra slash in HTTP requests to the URL, preventing JIRA from working properly. Closes #42494
This commit is contained in:
parent
1f309b69df
commit
8f965d0fa3
|
@ -43,7 +43,7 @@ class JiraService < IssueTrackerService
|
||||||
username: self.username,
|
username: self.username,
|
||||||
password: self.password,
|
password: self.password,
|
||||||
site: URI.join(url, '/').to_s,
|
site: URI.join(url, '/').to_s,
|
||||||
context_path: url.path,
|
context_path: url.path.chomp('/'),
|
||||||
auth_type: :basic,
|
auth_type: :basic,
|
||||||
read_timeout: 120,
|
read_timeout: 120,
|
||||||
use_cookies: true,
|
use_cookies: true,
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Fix JIRA not working when a trailing slash is included
|
||||||
|
merge_request:
|
||||||
|
author:
|
||||||
|
type: fixed
|
|
@ -3,6 +3,29 @@ require 'spec_helper'
|
||||||
describe JiraService do
|
describe JiraService do
|
||||||
include Gitlab::Routing
|
include Gitlab::Routing
|
||||||
|
|
||||||
|
describe '#options' do
|
||||||
|
let(:service) do
|
||||||
|
described_class.new(
|
||||||
|
project: build_stubbed(:project),
|
||||||
|
active: true,
|
||||||
|
username: 'username',
|
||||||
|
password: 'test',
|
||||||
|
jira_issue_transition_id: 24,
|
||||||
|
url: 'http://jira.test.com/path/'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'sets the URL properly' do
|
||||||
|
# jira-ruby gem parses the URI and handles trailing slashes
|
||||||
|
# fine: https://github.com/sumoheavy/jira-ruby/blob/v1.4.1/lib/jira/http_client.rb#L59
|
||||||
|
expect(service.options[:site]).to eq('http://jira.test.com/')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'leaves out trailing slashes in context' do
|
||||||
|
expect(service.options[:context_path]).to eq('/path')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "Associations" do
|
describe "Associations" do
|
||||||
it { is_expected.to belong_to :project }
|
it { is_expected.to belong_to :project }
|
||||||
it { is_expected.to have_one :service_hook }
|
it { is_expected.to have_one :service_hook }
|
||||||
|
|
Loading…
Reference in New Issue