From 2f1b1ba5fe6a09ca58c15f78d8a0577c5515c87c Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Thu, 18 Apr 2024 18:16:22 +0200 Subject: [PATCH] fix(mailers): hardcode default url options host because APP_HOST is not yet migrated --- .../concerns/mailer_defaults_configurable_concern.rb | 2 +- spec/mailers/devise_user_mailer_spec.rb | 6 +++--- spec/mailers/dossier_mailer_spec.rb | 4 ++-- spec/mailers/notification_mailer_spec.rb | 2 +- spec/mailers/user_mailer_spec.rb | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/mailers/concerns/mailer_defaults_configurable_concern.rb b/app/mailers/concerns/mailer_defaults_configurable_concern.rb index 0bf67ba86..de256157f 100644 --- a/app/mailers/concerns/mailer_defaults_configurable_concern.rb +++ b/app/mailers/concerns/mailer_defaults_configurable_concern.rb @@ -57,7 +57,7 @@ module MailerDefaultsConfigurableConcern def set_currents_for_demarches_gouv_fr Current.application_name = "demarches.gouv.fr" - Current.host = ENV.fetch("APP_HOST") + Current.host = "demarches.gouv.fr" Current.contact_email = "contact@demarches.gouv.fr" Current.no_reply_email = NO_REPLY_EMAIL.sub("demarches-simplifiees.fr", "demarches.gouv.fr") # rubocop:disable DS/ApplicationName end diff --git a/spec/mailers/devise_user_mailer_spec.rb b/spec/mailers/devise_user_mailer_spec.rb index 1b6160c6b..ed0e946ff 100644 --- a/spec/mailers/devise_user_mailer_spec.rb +++ b/spec/mailers/devise_user_mailer_spec.rb @@ -57,8 +57,8 @@ RSpec.describe DeviseUserMailer, type: :mailer do it "respect preferred domain" do expect(header_value("From", subject.message)).to eq("Ne pas répondre ") expect(header_value("Reply-To", subject.message)).to eq("Ne pas répondre ") - expect(subject.message.to_s).to include("#{ENV.fetch("APP_HOST")}/users/confirmation") - expect(subject.message.to_s).to include("//#{ENV.fetch("APP_HOST")}/assets/mailer/republique") + expect(subject.message.to_s).to include("demarches.gouv.fr/users/confirmation") + expect(subject.message.to_s).to include("//demarches.gouv.fr/assets/mailer/republique") end end end @@ -78,7 +78,7 @@ RSpec.describe DeviseUserMailer, type: :mailer do it "respect preferred domain" do expect(header_value("From", subject.message)).to include("@demarches.gouv.fr") - expect(subject.message.to_s).to include("#{ENV.fetch("APP_HOST")}/users/password") + expect(subject.message.to_s).to include("demarches.gouv.fr/users/password") end end end diff --git a/spec/mailers/dossier_mailer_spec.rb b/spec/mailers/dossier_mailer_spec.rb index c018b7df1..e142ddb40 100644 --- a/spec/mailers/dossier_mailer_spec.rb +++ b/spec/mailers/dossier_mailer_spec.rb @@ -32,7 +32,7 @@ RSpec.describe DossierMailer, type: :mailer do let(:user) { create(:user, preferred_domain: :demarches_gouv_fr) } it 'includes the correct body content and sender email' do - expect(subject.body).to include(dossier_url(dossier, host: ENV.fetch('APP_HOST'))) + expect(subject.body).to include(dossier_url(dossier, host: 'demarches.gouv.fr')) expect(header_value("From", subject)).to include("ne-pas-repondre@demarches.gouv.fr") end end @@ -333,7 +333,7 @@ RSpec.describe DossierMailer, type: :mailer do context 'when recipient has preferred domain' do let(:dossier_transfer) { create(:dossier_transfer, email: create(:user, preferred_domain: :demarches_gouv_fr).email) } it 'includes a link with the preferred domain in the email body' do - expect(subject.body).to include(dossiers_url(statut: "dossiers-transferes", host: ENV.fetch("APP_HOST"))) + expect(subject.body).to include(dossiers_url(statut: "dossiers-transferes", host: 'demarches.gouv.fr')) end end diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb index 74308afb5..e6222596a 100644 --- a/spec/mailers/notification_mailer_spec.rb +++ b/spec/mailers/notification_mailer_spec.rb @@ -112,7 +112,7 @@ RSpec.describe NotificationMailer, type: :mailer do let(:user) { create(:user, preferred_domain: :demarches_gouv_fr) } it 'adjusts links and sender email for user preferred domain' do - expect(mail.body).to have_link(href: dossier_url(dossier, host: ENV.fetch("APP_HOST"))) + expect(mail.body).to have_link(href: dossier_url(dossier, host: 'demarches.gouv.fr')) expect(header_value("From", mail)).to include("@demarches.gouv.fr") end end diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb index 47ad40331..7b6ef9641 100644 --- a/spec/mailers/user_mailer_spec.rb +++ b/spec/mailers/user_mailer_spec.rb @@ -21,7 +21,7 @@ RSpec.describe UserMailer, type: :mailer do let(:user) { create(:user, preferred_domain: :demarches_gouv_fr) } it do - expect(subject.body).to have_link("Commencer la démarche « #{procedure.libelle} »", href: commencer_sign_in_url(path: procedure.path, host: ENV.fetch("APP_HOST"))) + expect(subject.body).to have_link("Commencer la démarche « #{procedure.libelle} »", href: commencer_sign_in_url(path: procedure.path, host: "demarches.gouv.fr")) expect(header_value("From", subject)).to include("@demarches.gouv.fr") end end