Commit 5fdb7ced authored by Robert Speicher's avatar Robert Speicher

Merge branch 'pl-nil-guard-extract-sentry-external-url' into 'master'

Fix extracting Sentry external URL when URL is nil

See merge request gitlab-org/gitlab!23162
parents 27bcc37e a5a94d13
......@@ -128,7 +128,7 @@ module ErrorTracking
# ->
# http://HOST/ORG/PROJECT
def self.extract_sentry_external_url(url)
url.sub('api/0/projects/', '')
url&.sub('api/0/projects/', '')
end
def api_host
......
---
title: Fix extracting Sentry external URL when URL is nil
merge_request: 23162
author:
type: fixed
......@@ -64,6 +64,22 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
end
end
describe '.extract_sentry_external_url' do
subject { described_class.extract_sentry_external_url(sentry_url) }
describe 'when passing a URL' do
let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' }
it { is_expected.to eq('https://sentrytest.gitlab.com/sentry-org/sentry-project') }
end
describe 'when passing nil' do
let(:sentry_url) { nil }
it { is_expected.to be_nil }
end
end
describe '#sentry_external_url' do
let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' }
......
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