Commit f82da155 authored by David Fernandez's avatar David Fernandez

Merge branch '334344-jira-blank-web-url' into 'master'

Return empty strings for Jira links when URL is not set

See merge request gitlab-org/gitlab!65547
parents 247ff256 746cfabf
...@@ -155,7 +155,7 @@ module Integrations ...@@ -155,7 +155,7 @@ module Integrations
end end
def web_url(path = nil, **params) def web_url(path = nil, **params)
return unless url.present? return '' unless url.present?
if Gitlab.com? if Gitlab.com?
params.merge!(ATLASSIAN_REFERRER_GITLAB_COM) unless Gitlab.staging? params.merge!(ATLASSIAN_REFERRER_GITLAB_COM) unless Gitlab.staging?
......
...@@ -1024,6 +1024,12 @@ RSpec.describe Integrations::Jira do ...@@ -1024,6 +1024,12 @@ RSpec.describe Integrations::Jira do
expect(integration.web_url('subpath', bar: 'baz baz')).to eq('http://jira.test.com/path/subpath?bar=baz%20baz&foo=bar%20bar&nosso') expect(integration.web_url('subpath', bar: 'baz baz')).to eq('http://jira.test.com/path/subpath?bar=baz%20baz&foo=bar%20bar&nosso')
end end
it 'returns an empty string if URL is not set' do
integration.url = nil
expect(integration.web_url).to eq('')
end
it 'includes Atlassian referrer for gitlab.com' do it 'includes Atlassian referrer for gitlab.com' do
allow(Gitlab).to receive(:com?).and_return(true) allow(Gitlab).to receive(:com?).and_return(true)
...@@ -1041,16 +1047,40 @@ RSpec.describe Integrations::Jira do ...@@ -1041,16 +1047,40 @@ RSpec.describe Integrations::Jira do
end end
end end
describe '#project_url' do
it 'returns the correct URL' do
expect(integration.project_url).to eq('http://jira.test.com/path')
end
it 'returns an empty string if URL is not set' do
integration.url = nil
expect(integration.project_url).to eq('')
end
end
describe '#issues_url' do describe '#issues_url' do
it 'returns the correct URL' do it 'returns the correct URL' do
expect(integration.issues_url).to eq('http://jira.test.com/path/browse/:id') expect(integration.issues_url).to eq('http://jira.test.com/path/browse/:id')
end end
it 'returns an empty string if URL is not set' do
integration.url = nil
expect(integration.issues_url).to eq('')
end
end end
describe '#new_issue_url' do describe '#new_issue_url' do
it 'returns the correct URL' do it 'returns the correct URL' do
expect(integration.new_issue_url).to eq('http://jira.test.com/path/secure/CreateIssue!default.jspa') expect(integration.new_issue_url).to eq('http://jira.test.com/path/secure/CreateIssue!default.jspa')
end end
it 'returns an empty string if URL is not set' do
integration.url = nil
expect(integration.new_issue_url).to eq('')
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment