Commit 92723760 authored by Sean Arnold's avatar Sean Arnold

Fix image path in escalation email

Add specs for change in behaviour
parent b72dae3f
......@@ -45,7 +45,6 @@ module EE
def incident_escalation_fired_email(project, user, issue)
@project = project
@incident = issue.present
@escalation_status = issue.incident_management_issuable_escalation_status
add_project_headers
......
......@@ -33,7 +33,7 @@ class IssuableMetricImage < ApplicationRecord
return file&.url unless file&.upload
# If we're using a CDN, we need to use the full URL
asset_host = ActionController::Base.asset_host
asset_host = ActionController::Base.asset_host || Gitlab.config.gitlab.base_url
local_path = Gitlab::Routing.url_helpers.issuable_metric_image_upload_path(
filename: file.filename,
id: file.upload.model_id,
......
......@@ -23,4 +23,4 @@
%p
= _('Metrics:')
- @incident.metric_images.each do |image|
= link_to image.filename, image.url
= link_to image.filename, image.file_path
......@@ -12,3 +12,10 @@
<% if @escalation_status.policy %>
<%= _('Escalation policy:') %> <%= @escalation_status.policy.name %>
<% end %>
<% if @incident.metric_images.any? %>
<%= _('Metrics:') %>
<% @incident.metric_images.each do |image| %>
<%= image.file_path %>
<% end %>
<% end %>
......@@ -60,4 +60,27 @@ RSpec.describe IssuableMetricImage do
it { is_expected.to eq(false) }
end
end
describe '#file_path' do
let(:issuable_metric_image) { create(:issuable_metric_image) }
let(:expected_path) { issuable_metric_image.file.url }
subject(:file_path) { issuable_metric_image.file_path }
context 'with asset host configured' do
it 'returns a full URL with the asset host and system path' do
asset_host = 'https://gitlab-assets.example.com'
allow(ActionController::Base).to receive(:asset_host) { asset_host }
expect(file_path).to eq("#{asset_host}#{expected_path}")
end
end
context 'no asset path configured' do
it 'returns a full URL with the base url and system path' do
base_url = Gitlab.config.gitlab.base_url
expect(file_path).to eq("#{base_url}#{expected_path}")
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