feat(mail): link with hosts for recipient for notification mailer
This commit is contained in:
parent
f8a9e72aa2
commit
5bf580b6ac
3 changed files with 17 additions and 4 deletions
|
@ -27,7 +27,8 @@ module MailerHeadersConfigurableConcern
|
|||
end
|
||||
|
||||
self.class.default from: from, reply_to: from
|
||||
self.class.default_url_options = { host: Current.host }
|
||||
self.class.default_url_options[:host] = Current.host
|
||||
Rails.application.routes.default_url_options[:host] = Current.host # link generated by url helpers in tags substitutions
|
||||
self.class.asset_host = Current.application_base_url
|
||||
end
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@ class NotificationMailer < ApplicationMailer
|
|||
return
|
||||
end
|
||||
|
||||
configure_defaults_for_user(@dossier.user)
|
||||
|
||||
@subject = "Votre dossier rempli par le mandataire #{@dossier.mandataire_first_name} #{@dossier.mandataire_last_name} a été mis à jour"
|
||||
@email = @dossier.individual.email
|
||||
@logo_url = procedure_logo_url(@dossier.procedure)
|
||||
|
@ -78,6 +80,7 @@ class NotificationMailer < ApplicationMailer
|
|||
|
||||
def set_dossier
|
||||
@dossier = params[:dossier]
|
||||
configure_defaults_for_user(@dossier.user)
|
||||
|
||||
if @dossier.skip_user_notification_email?
|
||||
mail.perform_deliveries = false
|
||||
|
|
|
@ -73,8 +73,8 @@ RSpec.describe NotificationMailer, type: :mailer do
|
|||
end
|
||||
|
||||
it 'renders the actions' do
|
||||
expect(mail.body).to have_link('Consulter mon dossier', href: dossier_url(dossier))
|
||||
expect(mail.body).to have_link('J’ai une question', href: messagerie_dossier_url(dossier))
|
||||
expect(mail.body).to have_link('Consulter mon dossier', href: dossier_url(dossier, host: ENV.fetch("APP_HOST_LEGACY")))
|
||||
expect(mail.body).to have_link('J’ai une question', href: messagerie_dossier_url(dossier, host: ENV.fetch("APP_HOST_LEGACY")))
|
||||
end
|
||||
|
||||
context 'when the template body contains tags' do
|
||||
|
@ -85,7 +85,16 @@ RSpec.describe NotificationMailer, type: :mailer do
|
|||
end
|
||||
|
||||
it 'replaces link tags with a clickable link' do
|
||||
expect(mail.body).to have_link(dossier_url(dossier))
|
||||
expect(mail.body).to have_link(dossier_url(dossier, host: ENV.fetch("APP_HOST_LEGACY")))
|
||||
end
|
||||
|
||||
context "when user has preferred domain" do
|
||||
let(:user) { create(:user, preferred_domain: :demarches_gouv_fr) }
|
||||
|
||||
it do
|
||||
expect(mail.body).to have_link(dossier_url(dossier, host: ENV.fetch("APP_HOST")))
|
||||
expect(header_value("From", mail)).to include("@demarches.gouv.fr")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue