Commit ad1f7390 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'fix/run-smime-email-interceptor-last' into 'master'

Fix premailer and S/MIME emailer hooks order

Closes #197363

See merge request gitlab-org/gitlab!23293
parents 29c46433 2a447d35
---
title: Fix premailer and S/MIME emailer hooks order
merge_request: 23293
author: Diego Louzán
type: fixed
...@@ -11,6 +11,9 @@ ActionMailer::Base.register_interceptors( ...@@ -11,6 +11,9 @@ ActionMailer::Base.register_interceptors(
ActionMailer::Base.register_observer(::Gitlab::Email::Hook::DeliveryMetricsObserver) ActionMailer::Base.register_observer(::Gitlab::Email::Hook::DeliveryMetricsObserver)
# Force premailer loading so that it's not configured to run after the S/MIME interceptor
::Premailer::Rails.register_interceptors
if Gitlab.config.gitlab.email_enabled && Gitlab.config.gitlab.email_smime.enabled if Gitlab.config.gitlab.email_enabled && Gitlab.config.gitlab.email_smime.enabled
ActionMailer::Base.register_interceptor(::Gitlab::Email::Hook::SmimeSignatureInterceptor) ActionMailer::Base.register_interceptor(::Gitlab::Email::Hook::SmimeSignatureInterceptor)
Gitlab::AppLogger.debug "S/MIME signing of outgoing emails enabled" Gitlab::AppLogger.debug "S/MIME signing of outgoing emails enabled"
......
...@@ -35,8 +35,11 @@ describe 'ActionMailer hooks' do ...@@ -35,8 +35,11 @@ describe 'ActionMailer hooks' do
load Rails.root.join('config/initializers/action_mailer_hooks.rb') load Rails.root.join('config/initializers/action_mailer_hooks.rb')
if smime_interceptor_enabled if smime_interceptor_enabled
# Premailer must be registered before S/MIME or signatures will be mangled
expect(ActionMailer::Base).to( expect(ActionMailer::Base).to(
have_received(:register_interceptor).with(Gitlab::Email::Hook::SmimeSignatureInterceptor)) have_received(:register_interceptor).with(::Premailer::Rails::Hook).ordered)
expect(ActionMailer::Base).to(
have_received(:register_interceptor).with(Gitlab::Email::Hook::SmimeSignatureInterceptor).ordered)
else else
expect(ActionMailer::Base).not_to( expect(ActionMailer::Base).not_to(
have_received(:register_interceptor).with(Gitlab::Email::Hook::SmimeSignatureInterceptor)) have_received(:register_interceptor).with(Gitlab::Email::Hook::SmimeSignatureInterceptor))
......
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