From 863784a1a97265e4678747e845e365a9e323b782 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Wed, 27 Mar 2024 09:06:42 +0100 Subject: [PATCH 01/14] test: configure default host on APP_HOST everywhere --- config/environments/test.rb | 4 ++-- spec/models/concern/mail_template_concern_spec.rb | 6 +++--- spec/serializers/procedure_serializer_spec.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/environments/test.rb b/config/environments/test.rb index 4a01914e6..3f79b3b0f 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -63,9 +63,9 @@ Rails.application.configure do # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true - config.action_mailer.default_url_options = { :host => 'localhost:3000' } + config.action_mailer.default_url_options = { host: ENV.fetch("APP_HOST") } Rails.application.routes.default_url_options = { - host: 'localhost:3000', + host: ENV.fetch("APP_HOST"), protocol: :http } diff --git a/spec/models/concern/mail_template_concern_spec.rb b/spec/models/concern/mail_template_concern_spec.rb index e33adb3d2..965d8432f 100644 --- a/spec/models/concern/mail_template_concern_spec.rb +++ b/spec/models/concern/mail_template_concern_spec.rb @@ -25,7 +25,7 @@ describe MailTemplateConcern do it do expected = "[demarches-simplifiees.fr] #{dossier.id} #{dossier.procedure.libelle} " + - "http://localhost:3000/dossiers/#{dossier.id}" + "http://test.host/dossiers/#{dossier.id}" is_expected.to eq(expected) end @@ -75,7 +75,7 @@ describe MailTemplateConcern do describe "in closed mail without justificatif" do let(:mail) { create(:closed_mail, procedure: procedure) } - it { is_expected.to eq("http://localhost:3000/dossiers/#{dossier.id}/attestation") } + it { is_expected.to eq("http://test.host/dossiers/#{dossier.id}/attestation") } it { is_expected.to_not include("Télécharger le justificatif") } end @@ -86,7 +86,7 @@ describe MailTemplateConcern do let(:mail) { create(:closed_mail, procedure: procedure) } it { expect(dossier.justificatif_motivation).to be_attached } - it { is_expected.to include("http://localhost:3000/dossiers/#{dossier.id}/attestation") } + it { is_expected.to include("http://test.host/dossiers/#{dossier.id}/attestation") } it { is_expected.to_not include("Télécharger le justificatif") } end diff --git a/spec/serializers/procedure_serializer_spec.rb b/spec/serializers/procedure_serializer_spec.rb index 55eeaa000..919bf53ee 100644 --- a/spec/serializers/procedure_serializer_spec.rb +++ b/spec/serializers/procedure_serializer_spec.rb @@ -4,7 +4,7 @@ describe ProcedureSerializer do let(:procedure) { create(:procedure, :published) } it { - is_expected.to include(link: "http://localhost:3000/commencer/#{procedure.path}") + is_expected.to include(link: "http://test.host/commencer/#{procedure.path}") is_expected.to include(state: "publiee") } end From d14fe83261d88dc84ca803b84ee476b9f9a119d4 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Mon, 25 Mar 2024 19:13:09 +0100 Subject: [PATCH 02/14] feat(mail): devise confirmation instructions respect user preferred host --- .../mailer_headers_configurable_concern.rb | 26 +++++++++++++++ app/mailers/devise_user_mailer.rb | 6 +++- app/models/current.rb | 11 +++++-- spec/mailers/devise_user_mailer_spec.rb | 33 +++++++++++++++++-- 4 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 app/mailers/concerns/mailer_headers_configurable_concern.rb diff --git a/app/mailers/concerns/mailer_headers_configurable_concern.rb b/app/mailers/concerns/mailer_headers_configurable_concern.rb new file mode 100644 index 000000000..41eec28cd --- /dev/null +++ b/app/mailers/concerns/mailer_headers_configurable_concern.rb @@ -0,0 +1,26 @@ +module MailerHeadersConfigurableConcern + extend ActiveSupport::Concern + + included do + def configure_defaults_for_user(user) + I18n.locale = user.locale + + if user.preferred_domain_demarches_gouv_fr? + Current.application_name = "demarches.gouv.fr" + Current.host = ENV.fetch("APP_HOST") + 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 + else + Current.application_name = APPLICATION_NAME + Current.host = ENV["APP_HOST_LEGACY"] || ENV.fetch("APP_HOST") # _LEGACY is optional, fallbagck to default when unset + Current.contact_email = CONTACT_EMAIL + Current.no_reply_email = NO_REPLY_EMAIL + end + + from = "#{Current.application_name} <#{Current.contact_email}>" + self.class.default from: from, reply_to: from + self.class.default_url_options = { host: Current.host } + self.class.asset_host = Current.application_base_url + end + end +end diff --git a/app/mailers/devise_user_mailer.rb b/app/mailers/devise_user_mailer.rb index 4c910341f..a37931415 100644 --- a/app/mailers/devise_user_mailer.rb +++ b/app/mailers/devise_user_mailer.rb @@ -5,6 +5,7 @@ class DeviseUserMailer < Devise::Mailer include Devise::Controllers::UrlHelpers # Optional. eg. `confirmation_url` include MailerDolistConcern include MailerMonitoringConcern + include MailerHeadersConfigurableConcern include BalancedDeliveryConcern include PriorityDeliveryConcern @@ -15,7 +16,10 @@ class DeviseUserMailer < Devise::Mailer end def confirmation_instructions(record, token, opts = {}) - opts[:from] = NO_REPLY_EMAIL + configure_defaults_for_user(record) + + opts[:from] = Current.no_reply_email + opts[:reply_to] = Current.no_reply_email @procedure = opts[:procedure_after_confirmation] || nil @prefill_token = opts[:prefill_token] super diff --git a/app/models/current.rb b/app/models/current.rb index 62d42747c..4b18adc10 100644 --- a/app/models/current.rb +++ b/app/models/current.rb @@ -1,5 +1,10 @@ class Current < ActiveSupport::CurrentAttributes - attribute :user, :request_id, :browser, - :host, :application_name, :contact_email, - :application_base_url + attribute :application_base_url + attribute :application_name + attribute :browser + attribute :contact_email + attribute :host + attribute :no_reply_email + attribute :request_id + attribute :user end diff --git a/spec/mailers/devise_user_mailer_spec.rb b/spec/mailers/devise_user_mailer_spec.rb index e0093028c..4f92bd4be 100644 --- a/spec/mailers/devise_user_mailer_spec.rb +++ b/spec/mailers/devise_user_mailer_spec.rb @@ -16,8 +16,37 @@ RSpec.describe DeviseUserMailer, type: :mailer do context 'when perform_later is called' do it 'enqueues email in default queue for high priority delivery' do - expect { subject.deliver_later }.to have_enqueued_job.on_queue(Rails.application.config.action_mailer.deliver_later_queue_name) -end + expect { subject.deliver_later }.to have_enqueued_job.on_queue(Rails.application.config.action_mailer.deliver_later_queue_name) + end end end + + describe 'headers for user' do + context "confirmation email" do + subject { described_class.confirmation_instructions(user, token, opts = {}) } + + context "legacy domain" do + it "respect preferred domain" do + expect(header_value("From", subject.message)).to eq(NO_REPLY_EMAIL) + expect(header_value("Reply-To", subject.message)).to eq(NO_REPLY_EMAIL) + expect(subject.message.to_s).to include("#{ENV.fetch("APP_HOST_LEGACY")}/users/confirmation") + end + end + + context "new domain" do + let(:user) { create(:user, preferred_domain: :demarches_gouv_fr) } + + 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") + end + end + end + end + + def header_value(name, message) + message.header.fields.find { _1.name == name }.value + end end From 3512e071d315df889652550d7958cad7f4caae6f Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Mon, 25 Mar 2024 20:12:12 +0100 Subject: [PATCH 03/14] feat(mail): devise mailer respect user preferred host for any mail --- app/mailers/devise_user_mailer.rb | 11 +++++++++++ spec/mailers/devise_user_mailer_spec.rb | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/app/mailers/devise_user_mailer.rb b/app/mailers/devise_user_mailer.rb index a37931415..03ee64bcb 100644 --- a/app/mailers/devise_user_mailer.rb +++ b/app/mailers/devise_user_mailer.rb @@ -10,11 +10,22 @@ class DeviseUserMailer < Devise::Mailer include PriorityDeliveryConcern layout 'mailers/layout' + default from: "#{APPLICATION_NAME} <#{CONTACT_EMAIL}>" def template_paths ['devise_mailer'] end + # Note: this devise hook (like any callback) is called *after* the action, + # because we use mailers with Mailer.action_name() syntax + # instead of parameterized Mailer.with().action_name. + # So any action using Current must manually call `configure_defaults_for_user` + def initialize_from_record(record) + configure_defaults_for_user(record) + + super + end + def confirmation_instructions(record, token, opts = {}) configure_defaults_for_user(record) diff --git a/spec/mailers/devise_user_mailer_spec.rb b/spec/mailers/devise_user_mailer_spec.rb index 4f92bd4be..e04c04ff3 100644 --- a/spec/mailers/devise_user_mailer_spec.rb +++ b/spec/mailers/devise_user_mailer_spec.rb @@ -44,6 +44,26 @@ RSpec.describe DeviseUserMailer, type: :mailer do end end end + + context "reset password instructions" do + subject { described_class.reset_password_instructions(user, token) } + + context "legacy domain" do + it "respect preferred domain" do + expect(header_value("From", subject.message)).to include(CONTACT_EMAIL) + expect(subject.message.to_s).to include("#{ENV.fetch("APP_HOST_LEGACY")}/users/password") + end + end + + context "new domain" do + let(:user) { create(:user, preferred_domain: :demarches_gouv_fr) } + + 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") + end + end + end end def header_value(name, message) From f8a9e72aa25e5d2d6c27367393cadcc4e526a7af Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Wed, 27 Mar 2024 09:16:40 +0100 Subject: [PATCH 04/14] feat(mail): from and link with host for recipient in dossier_mailer --- .env.test | 1 + app/mailers/application_mailer.rb | 1 + .../mailer_headers_configurable_concern.rb | 16 ++++++++- app/mailers/dossier_mailer.rb | 34 +++++++++++++++++++ spec/mailers/devise_user_mailer_spec.rb | 4 --- spec/mailers/dossier_mailer_spec.rb | 23 ++++++++++--- spec/support/mailer.rb | 5 +++ 7 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 spec/support/mailer.rb diff --git a/.env.test b/.env.test index e812b63bd..2e886cf8e 100644 --- a/.env.test +++ b/.env.test @@ -1 +1,2 @@ APP_HOST="test.host" # must match host defined in spec/rails_helper.rb +APP_HOST_LEGACY="test-legacy.host" diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 692b3f4e0..9d1345a1a 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,5 +1,6 @@ class ApplicationMailer < ActionMailer::Base include MailerDolistConcern + include MailerHeadersConfigurableConcern include MailerMonitoringConcern include BalancedDeliveryConcern include PriorityDeliveryConcern diff --git a/app/mailers/concerns/mailer_headers_configurable_concern.rb b/app/mailers/concerns/mailer_headers_configurable_concern.rb index 41eec28cd..03c07491a 100644 --- a/app/mailers/concerns/mailer_headers_configurable_concern.rb +++ b/app/mailers/concerns/mailer_headers_configurable_concern.rb @@ -3,6 +3,8 @@ module MailerHeadersConfigurableConcern included do def configure_defaults_for_user(user) + return if user.nil? || !user.is_a?(User) # not for super-admins + I18n.locale = user.locale if user.preferred_domain_demarches_gouv_fr? @@ -17,10 +19,22 @@ module MailerHeadersConfigurableConcern Current.no_reply_email = NO_REPLY_EMAIL end - from = "#{Current.application_name} <#{Current.contact_email}>" + @@original_default_from ||= self.class.default[:from] + from = if @@original_default_from.include?(NO_REPLY_EMAIL) + Current.no_reply_email + else + "#{Current.application_name} <#{Current.contact_email}>" + end + self.class.default from: from, reply_to: from self.class.default_url_options = { host: Current.host } self.class.asset_host = Current.application_base_url end + + def configure_defaults_for_email(email) + user = User.find_by(email: email) + + configure_defaults_for_user(user) + end end end diff --git a/app/mailers/dossier_mailer.rb b/app/mailers/dossier_mailer.rb index d41197019..1064af740 100644 --- a/app/mailers/dossier_mailer.rb +++ b/app/mailers/dossier_mailer.rb @@ -17,6 +17,8 @@ class DossierMailer < ApplicationMailer def notify_new_draft @dossier = params[:dossier] + configure_defaults_for_user(@dossier.user) + I18n.with_locale(@dossier.user_locale) do @service = @dossier.procedure.service @logo_url = procedure_logo_url(@dossier.procedure) @@ -31,6 +33,8 @@ class DossierMailer < ApplicationMailer def notify_new_answer commentaire = params[:commentaire] dossier = commentaire.dossier + configure_defaults_for_user(dossier.user) + I18n.with_locale(dossier.user_locale) do @dossier = dossier @service = dossier.procedure.service @@ -45,6 +49,8 @@ class DossierMailer < ApplicationMailer end def notify_new_commentaire_to_instructeur(dossier, instructeur_email) + configure_defaults_for_email(instructeur_email) + I18n.with_locale(dossier.user_locale) do @dossier = dossier @subject = default_i18n_subject(dossier_id: dossier.id, libelle_demarche: dossier.procedure.libelle) @@ -56,6 +62,8 @@ class DossierMailer < ApplicationMailer def notify_pending_correction commentaire = params[:commentaire] dossier = commentaire.dossier + configure_defaults_for_user(dossier.user) + I18n.with_locale(dossier.user_locale) do @dossier = dossier @service = dossier.procedure.service @@ -71,6 +79,8 @@ class DossierMailer < ApplicationMailer end def notify_new_avis_to_instructeur(avis, instructeur_email) + configure_defaults_for_email(instructeur_email) + I18n.with_locale(avis.dossier.user_locale) do @avis = avis @subject = default_i18n_subject(dossier_id: avis.dossier.id, libelle_demarche: avis.procedure.libelle) @@ -80,6 +90,8 @@ class DossierMailer < ApplicationMailer end def notify_new_dossier_depose_to_instructeur(dossier, instructeur_email) + configure_defaults_for_email(instructeur_email) + I18n.with_locale(dossier.user_locale) do @dossier = dossier @subject = default_i18n_subject(dossier_id: dossier.id, libelle_demarche: dossier.procedure.libelle) @@ -89,6 +101,8 @@ class DossierMailer < ApplicationMailer end def notify_brouillon_near_deletion(dossiers, to_email) + configure_defaults_for_email(to_email) + I18n.with_locale(dossiers.first.user_locale) do @subject = default_i18n_subject(count: dossiers.size) @dossiers = dossiers @@ -98,6 +112,8 @@ class DossierMailer < ApplicationMailer end def notify_brouillon_deletion(dossier_hashes, to_email) + configure_defaults_for_email(to_email) + @subject = default_i18n_subject(count: dossier_hashes.size) @dossier_hashes = dossier_hashes @@ -105,6 +121,8 @@ class DossierMailer < ApplicationMailer end def notify_en_construction_deletion_to_administration(dossier, to_email) + configure_defaults_for_email(to_email) + @subject = default_i18n_subject(dossier_id: dossier.id) @dossier = dossier @@ -112,6 +130,8 @@ class DossierMailer < ApplicationMailer end def notify_deletion_to_administration(deleted_dossier, to_email) + configure_defaults_for_email(to_email) + @subject = default_i18n_subject(dossier_id: deleted_dossier.dossier_id) @deleted_dossier = deleted_dossier @@ -119,6 +139,8 @@ class DossierMailer < ApplicationMailer end def notify_automatic_deletion_to_user(deleted_dossiers, to_email) + configure_defaults_for_email(to_email) + I18n.with_locale(deleted_dossiers.first.user_locale) do @state = deleted_dossiers.first.state @subject = default_i18n_subject(count: deleted_dossiers.size) @@ -129,6 +151,8 @@ class DossierMailer < ApplicationMailer end def notify_automatic_deletion_to_administration(deleted_dossiers, to_email) + configure_defaults_for_email(to_email) + @subject = default_i18n_subject(count: deleted_dossiers.size) @deleted_dossiers = deleted_dossiers @@ -136,6 +160,8 @@ class DossierMailer < ApplicationMailer end def notify_near_deletion_to_user(dossiers, to_email) + configure_defaults_for_email(to_email) + I18n.with_locale(dossiers.first.user_locale) do @state = dossiers.first.state @subject = default_i18n_subject(count: dossiers.size, state: @state) @@ -146,6 +172,8 @@ class DossierMailer < ApplicationMailer end def notify_near_deletion_to_administration(dossiers, to_email) + configure_defaults_for_email(to_email) + @state = dossiers.first.state @subject = default_i18n_subject(count: dossiers.size, state: @state) @dossiers = dossiers @@ -154,6 +182,8 @@ class DossierMailer < ApplicationMailer end def notify_groupe_instructeur_changed(instructeur, dossier) + configure_defaults_for_user(instructeur.user) + @subject = default_i18n_subject(dossier_id: dossier.id) @dossier = dossier @@ -161,6 +191,8 @@ class DossierMailer < ApplicationMailer end def notify_brouillon_not_submitted(dossier) + configure_defaults_for_user(dossier.user) + I18n.with_locale(dossier.user_locale) do @subject = default_i18n_subject(dossier_id: dossier.id) @dossier = dossier @@ -172,6 +204,8 @@ class DossierMailer < ApplicationMailer def notify_transfer @transfer = params[:dossier_transfer] + configure_defaults_for_email(@transfer.email) + I18n.with_locale(@transfer.user_locale) do @subject = default_i18n_subject() diff --git a/spec/mailers/devise_user_mailer_spec.rb b/spec/mailers/devise_user_mailer_spec.rb index e04c04ff3..c020e9e4f 100644 --- a/spec/mailers/devise_user_mailer_spec.rb +++ b/spec/mailers/devise_user_mailer_spec.rb @@ -65,8 +65,4 @@ RSpec.describe DeviseUserMailer, type: :mailer do end end end - - def header_value(name, message) - message.header.fields.find { _1.name == name }.value - end end diff --git a/spec/mailers/dossier_mailer_spec.rb b/spec/mailers/dossier_mailer_spec.rb index 4f00ee1d1..ebc951c88 100644 --- a/spec/mailers/dossier_mailer_spec.rb +++ b/spec/mailers/dossier_mailer_spec.rb @@ -12,18 +12,28 @@ RSpec.describe DossierMailer, type: :mailer do end describe '.notify_new_draft' do - let(:dossier) { create(:dossier, procedure: create(:simple_procedure, :with_auto_archive)) } + let(:user) { create(:user) } + let(:dossier) { create(:dossier, procedure: create(:simple_procedure, :with_auto_archive), user:) } subject { described_class.with(dossier:).notify_new_draft } it { expect(subject.subject).to include("brouillon") } it { expect(subject.subject).to include(dossier.procedure.libelle) } it { expect(subject.body).to include(dossier.procedure.libelle) } - it { expect(subject.body).to include(dossier_url(dossier)) } + it { expect(subject.body).to include(dossier_url(dossier, host: ENV.fetch("APP_HOST_LEGACY"))) } it { expect(subject.body).to include("Vous pouvez déposer votre dossier jusqu’au") } it { expect(subject.body).to include("heure de") } it_behaves_like 'a dossier notification' + + context "user prefers new domain" do + let(:user) { create(:user, preferred_domain: :demarches_gouv_fr) } + + it do + expect(subject.body).to include(dossier_url(dossier, host: ENV.fetch('APP_HOST'))) + expect(header_value("From", subject)).to include("ne-pas-repondre@demarches.gouv.fr") + end + end end describe '.notify_new_answer with dossier brouillon' do @@ -36,7 +46,7 @@ RSpec.describe DossierMailer, type: :mailer do it { expect(subject.subject).to include("Nouveau message") } it { expect(subject.subject).to include(dossier.id.to_s) } it { expect(subject.body).to include(dossier.procedure.service.email) } - it { expect(subject.body).not_to include(messagerie_dossier_url(dossier)) } + it { expect(subject.body).not_to include(messagerie_dossier_url(dossier, host: ENV.fetch("APP_HOST_LEGACY"))) } it_behaves_like 'a dossier notification' @@ -54,7 +64,7 @@ RSpec.describe DossierMailer, type: :mailer do it { expect(subject.subject).to include("Nouveau message") } it { expect(subject.subject).to include(dossier.id.to_s) } - it { expect(subject.body).to include(messagerie_dossier_url(dossier)) } + it { expect(subject.body).to include(messagerie_dossier_url(dossier, host: ENV.fetch("APP_HOST_LEGACY"))) } it_behaves_like 'a dossier notification' end @@ -280,6 +290,11 @@ RSpec.describe DossierMailer, type: :mailer do it { expect(subject.body).to include(procedure.libelle.to_s) } end + context 'when recipient has preferred domain' do + let(:dossier_transfer) { create(:dossier_transfer, email: create(:user, preferred_domain: :demarches_gouv_fr).email) } + it { expect(subject.body).to include(dossiers_url(statut: "dossiers-transferes", host: ENV.fetch("APP_HOST"))) } + end + context 'when it is a transfer of multiple dossiers' do let!(:dossier2) { create(:dossier, user: user, transfer: dossier_transfer, procedure: procedure) } it { expect(subject.subject).to include("Vous avez une demande de transfert en attente.") } diff --git a/spec/support/mailer.rb b/spec/support/mailer.rb new file mode 100644 index 000000000..7eb6169a4 --- /dev/null +++ b/spec/support/mailer.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +def header_value(name, message) + message.header.fields.find { _1.name == name }.value +end From 5bf580b6ac1fce80b16d8ace8a3b6f133797569e Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Tue, 26 Mar 2024 18:37:25 +0100 Subject: [PATCH 05/14] feat(mail): link with hosts for recipient for notification mailer --- .../mailer_headers_configurable_concern.rb | 3 ++- app/mailers/notification_mailer.rb | 3 +++ spec/mailers/notification_mailer_spec.rb | 15 ++++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/mailers/concerns/mailer_headers_configurable_concern.rb b/app/mailers/concerns/mailer_headers_configurable_concern.rb index 03c07491a..b5d1c1731 100644 --- a/app/mailers/concerns/mailer_headers_configurable_concern.rb +++ b/app/mailers/concerns/mailer_headers_configurable_concern.rb @@ -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 diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb index dab4dfaab..70f5b4091 100644 --- a/app/mailers/notification_mailer.rb +++ b/app/mailers/notification_mailer.rb @@ -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 diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb index 3ab227b22..0af291a71 100644 --- a/spec/mailers/notification_mailer_spec.rb +++ b/spec/mailers/notification_mailer_spec.rb @@ -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 From 21991d7253d34d144d2dc37fa03e29a708c478f7 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Tue, 26 Mar 2024 18:58:13 +0100 Subject: [PATCH 06/14] feat(mail): link with hosts for recipient for user mailer --- app/mailers/invite_mailer.rb | 2 ++ app/mailers/user_mailer.rb | 20 ++++++++++++++++++-- spec/mailers/user_mailer_spec.rb | 21 +++++++++++++++------ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/app/mailers/invite_mailer.rb b/app/mailers/invite_mailer.rb index d9c892b91..a769d5458 100644 --- a/app/mailers/invite_mailer.rb +++ b/app/mailers/invite_mailer.rb @@ -28,6 +28,8 @@ class InviteMailer < ApplicationMailer @invite = invite email = invite.email + configure_defaults_for_email(email) + mail(to: email, subject: subject, reply_to: reply_to) diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 0989b41c6..f45892699 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -9,6 +9,8 @@ class UserMailer < ApplicationMailer @subject = "Demande de création de compte" @procedure = procedure + configure_defaults_for_user(user) + mail(to: user.email, subject: @subject, procedure: @procedure) end @@ -17,6 +19,8 @@ class UserMailer < ApplicationMailer @requested_email = requested_email @subject = "Fusion de compte" + configure_defaults_for_email(requested_email) + mail(to: requested_email, subject: @subject) end @@ -25,6 +29,8 @@ class UserMailer < ApplicationMailer @email_merge_token_created_at = email_merge_token_created_at @subject = "Veuillez confirmer la fusion de compte" + configure_defaults_for_email(email) + mail(to: email, subject: @subject) end @@ -33,9 +39,11 @@ class UserMailer < ApplicationMailer @user = user subject = "Activez votre compte instructeur" + configure_defaults_for_user(user) + mail(to: user.email, subject: subject, - reply_to: CONTACT_EMAIL) + reply_to: Current.contact_email) end def invite_gestionnaire(user, reset_password_token, groupe_gestionnaire) @@ -44,12 +52,16 @@ class UserMailer < ApplicationMailer @groupe_gestionnaire = groupe_gestionnaire subject = "Activez votre compte gestionnaire" + configure_defaults_for_user(user) + mail(to: user.email, subject: subject, - reply_to: CONTACT_EMAIL) + reply_to: Current.contact_email) end def send_archive(administrateur_or_instructeur, procedure, archive) + configure_defaults_for_user(administrateur_or_instructeur.user) + @archive = archive @procedure = procedure @archive_url = case administrateur_or_instructeur @@ -71,6 +83,8 @@ class UserMailer < ApplicationMailer @user = user @subject = "Votre compte sera supprimé dans #{Expired::REMAINING_WEEKS_BEFORE_EXPIRATION} semaines" + configure_defaults_for_user(user) + mail(to: user.email, subject: @subject) end @@ -80,6 +94,8 @@ class UserMailer < ApplicationMailer @procedure = procedure @content = content + configure_defaults_for_user(user) + mail(to: user.email, subject: @subject, content: @content, procedure: @procedure) end diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb index 3bd017852..0ae0bc594 100644 --- a/spec/mailers/user_mailer_spec.rb +++ b/spec/mailers/user_mailer_spec.rb @@ -13,7 +13,16 @@ RSpec.describe UserMailer, type: :mailer do subject { described_class.new_account_warning(user, procedure) } - it { expect(subject.body).to have_link("Commencer la démarche « #{procedure.libelle} »", href: commencer_sign_in_url(path: procedure.path)) } + it { 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_LEGACY"))) } + + context "when user has preferred domain" 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(header_value("From", subject)).to include("@demarches.gouv.fr") + end + end end context 'without SafeMailer configured' do @@ -65,7 +74,7 @@ RSpec.describe UserMailer, type: :mailer do subject { described_class.france_connect_merge_confirmation(email, code, 15.minutes.from_now) } it { expect(subject.to).to eq([email]) } - it { expect(subject.body).to include(france_connect_particulier_mail_merge_with_existing_account_url(email_merge_token: code)) } + it { expect(subject.body).to include(france_connect_particulier_mail_merge_with_existing_account_url(email_merge_token: code))) } context 'without SafeMailer configured' do it { expect(subject[BalancerDeliveryMethod::FORCE_DELIVERY_METHOD_HEADER]&.value).to eq(nil) } @@ -92,15 +101,15 @@ RSpec.describe UserMailer, type: :mailer do context 'instructeur' do let(:role) { create(:instructeur) } it { expect(subject.to).to eq([role.user.email]) } - it { expect(subject.body).to have_link('Consulter mes archives', href: instructeur_archives_url(procedure)) } - it { expect(subject.body).to have_link("#{procedure.id} − #{procedure.libelle}", href: instructeur_procedure_url(procedure)) } + it { expect(subject.body).to have_link('Consulter mes archives', href: instructeur_archives_url(procedure, host: ENV.fetch("APP_HOST_LEGACY"))) } + it { expect(subject.body).to have_link("#{procedure.id} − #{procedure.libelle}", href: instructeur_procedure_url(procedure, host: ENV.fetch("APP_HOST_LEGACY"))) } end context 'instructeur' do let(:role) { create(:administrateur) } it { expect(subject.to).to eq([role.user.email]) } - it { expect(subject.body).to have_link('Consulter mes archives', href: admin_procedure_archives_url(procedure)) } - it { expect(subject.body).to have_link("#{procedure.id} − #{procedure.libelle}", href: admin_procedure_url(procedure)) } + it { expect(subject.body).to have_link('Consulter mes archives', href: admin_procedure_archives_url(procedure, host: ENV.fetch("APP_HOST_LEGACY"))) } + it { expect(subject.body).to have_link("#{procedure.id} − #{procedure.libelle}", href: admin_procedure_url(procedure, host: ENV.fetch("APP_HOST_LEGACY"))) } end context 'when perform_later is called' do From 8b9d4c87f7b155098cca7ce04d6ea65533bf8f8b Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Tue, 26 Mar 2024 20:00:54 +0100 Subject: [PATCH 07/14] refactor(mailer): more thread safe defaults tweaks --- app/mailers/application_mailer.rb | 2 +- .../mailer_defaults_configurable_concern.rb | 81 +++++++++++++++++++ .../mailer_headers_configurable_concern.rb | 41 ---------- app/mailers/devise_user_mailer.rb | 2 +- 4 files changed, 83 insertions(+), 43 deletions(-) create mode 100644 app/mailers/concerns/mailer_defaults_configurable_concern.rb delete mode 100644 app/mailers/concerns/mailer_headers_configurable_concern.rb diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 9d1345a1a..cb5124753 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,6 +1,6 @@ class ApplicationMailer < ActionMailer::Base + include MailerDefaultsConfigurableConcern include MailerDolistConcern - include MailerHeadersConfigurableConcern include MailerMonitoringConcern include BalancedDeliveryConcern include PriorityDeliveryConcern diff --git a/app/mailers/concerns/mailer_defaults_configurable_concern.rb b/app/mailers/concerns/mailer_defaults_configurable_concern.rb new file mode 100644 index 000000000..21310ff7c --- /dev/null +++ b/app/mailers/concerns/mailer_defaults_configurable_concern.rb @@ -0,0 +1,81 @@ +# frozen_string_literal: true + +module MailerDefaultsConfigurableConcern + extend ActiveSupport::Concern + + class_methods do + # Save original defaults before they're modified + def save_original_defaults + @original_default_from ||= self.default[:from] + @original_default_host ||= Rails.application.routes.default_url_options[:host] + @original_asset_host ||= asset_host + end + + # Resets mailer settings to their original values + def reset_original_defaults + default from: original_default_from, reply_to: original_default_from + default_url_options[:host] = original_default_host + Rails.application.routes.default_url_options[:host] = original_default_host + self.asset_host = original_asset_host + end + + def original_default_from = @original_default_from + def original_default_host = @original_default_host + def original_asset_host = @original_asset_host + end + + included do + before_action -> { self.class.save_original_defaults } + after_action -> { self.class.reset_original_defaults } + + def configure_defaults_for_user(user) + return if !user.is_a?(User) # not for super-admins + + I18n.locale = user.locale + + if user.preferred_domain_demarches_gouv_fr? + set_currents_for_demarches_gouv_fr + else + set_currents_for_legacy + end + + # Define mailer defaults + from = derive_from_header + self.class.default from: from, reply_to: from + self.class.default_url_options[:host] = Current.host + Rails.application.routes.default_url_options[:host] = Current.host + + original_uri = URI.parse(self.class.original_asset_host) # in local with have http://, but https:// in production + self.class.asset_host = "#{original_uri.scheme}://#{Current.host}" + end + + def configure_defaults_for_email(email) + user = User.find_by(email: email) + configure_defaults_for_user(user) + end + + private + + def set_currents_for_demarches_gouv_fr + Current.application_name = "demarches.gouv.fr" + Current.host = ENV.fetch("APP_HOST") + 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 + + def set_currents_for_legacy + Current.application_name = APPLICATION_NAME + Current.host = ENV["APP_HOST_LEGACY"] || ENV.fetch("APP_HOST") # APP_HOST_LEGACY is optional. Without it, we are in the situation withotu double domains + Current.contact_email = CONTACT_EMAIL + Current.no_reply_email = NO_REPLY_EMAIL + end + + def derive_from_header + if self.class.original_default_from.include?(NO_REPLY_EMAIL) + Current.no_reply_email + else + "#{Current.application_name} <#{Current.contact_email}>" + end + end + end +end diff --git a/app/mailers/concerns/mailer_headers_configurable_concern.rb b/app/mailers/concerns/mailer_headers_configurable_concern.rb deleted file mode 100644 index b5d1c1731..000000000 --- a/app/mailers/concerns/mailer_headers_configurable_concern.rb +++ /dev/null @@ -1,41 +0,0 @@ -module MailerHeadersConfigurableConcern - extend ActiveSupport::Concern - - included do - def configure_defaults_for_user(user) - return if user.nil? || !user.is_a?(User) # not for super-admins - - I18n.locale = user.locale - - if user.preferred_domain_demarches_gouv_fr? - Current.application_name = "demarches.gouv.fr" - Current.host = ENV.fetch("APP_HOST") - 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 - else - Current.application_name = APPLICATION_NAME - Current.host = ENV["APP_HOST_LEGACY"] || ENV.fetch("APP_HOST") # _LEGACY is optional, fallbagck to default when unset - Current.contact_email = CONTACT_EMAIL - Current.no_reply_email = NO_REPLY_EMAIL - end - - @@original_default_from ||= self.class.default[:from] - from = if @@original_default_from.include?(NO_REPLY_EMAIL) - Current.no_reply_email - else - "#{Current.application_name} <#{Current.contact_email}>" - end - - self.class.default from: from, reply_to: from - 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 - - def configure_defaults_for_email(email) - user = User.find_by(email: email) - - configure_defaults_for_user(user) - end - end -end diff --git a/app/mailers/devise_user_mailer.rb b/app/mailers/devise_user_mailer.rb index 03ee64bcb..fcebeb0e1 100644 --- a/app/mailers/devise_user_mailer.rb +++ b/app/mailers/devise_user_mailer.rb @@ -3,9 +3,9 @@ class DeviseUserMailer < Devise::Mailer helper :application # gives access to all helpers defined within `application_helper`. helper MailerHelper include Devise::Controllers::UrlHelpers # Optional. eg. `confirmation_url` + include MailerDefaultsConfigurableConcern include MailerDolistConcern include MailerMonitoringConcern - include MailerHeadersConfigurableConcern include BalancedDeliveryConcern include PriorityDeliveryConcern From 68ee4a340413fb00f7335def6980303c836aefa0 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Tue, 26 Mar 2024 17:23:42 +0100 Subject: [PATCH 08/14] feat(mail): use contextualized Current.application_name --- app/mailers/api_token_mailer.rb | 2 +- .../mailer_defaults_configurable_concern.rb | 3 +- app/mailers/instructeur_mailer.rb | 2 +- app/mailers/preactivate_users_mailer.rb | 10 +- app/mailers/resend_attestation_mailer.rb | 2 +- .../activate_before_expiration.haml | 2 +- ...procedure_expires_when_termine_forced.haml | 2 +- .../notify_service_without_siret.haml | 2 +- .../new_admin_email.html.haml | 2 +- .../refuse_admin.html.haml | 4 +- .../api_token_mailer/expiration.html.haml | 2 +- .../avis_mailer/avis_invitation.html.haml | 2 +- .../confirmation_instructions.en.html.haml | 4 +- .../confirmation_instructions.html.haml | 2 +- .../devise_mailer/email_changed.en.html.haml | 4 +- .../devise_mailer/email_changed.html.haml | 4 +- .../password_change.en.html.haml | 2 +- .../devise_mailer/password_change.html.haml | 2 +- .../reset_password_instructions.en.html.haml | 2 +- .../reset_password_instructions.html.haml | 2 +- .../unlock_instructions.en.html.haml | 2 +- .../unlock_instructions.html.haml | 2 +- .../notify_added_administrateurs.html.haml | 2 +- .../notify_added_gestionnaires.html.haml | 2 +- .../notify_removed_administrateur.html.haml | 2 +- .../notify_removed_gestionnaire.html.haml | 2 +- .../send_login_token.html.haml | 2 +- .../send_notifications.html.haml | 2 +- .../user_to_instructeur.html.haml | 2 +- .../invite_mailer/invite_guest.html.haml | 2 +- app/views/invite_mailer/invite_user.html.haml | 2 +- .../mailers/_bizdev_signature.html.haml | 2 +- ...taire_groupe_gestionnaire_footer.html.haml | 2 +- .../layouts/mailers/_signature.html.haml | 2 +- app/views/layouts/mailers/layout.html.erb | 4 +- .../mailers/notifications_layout.html.erb | 2 +- .../send_notification_for_tiers.html.haml | 2 +- .../user_mailer/invite_gestionnaire.html.haml | 2 +- .../user_mailer/invite_instructeur.html.haml | 4 +- .../user_mailer/new_account_warning.html.haml | 2 +- ...otify_inactive_close_to_deletion.html.haml | 2 +- spec/mailers/dossier_mailer_spec.rb | 214 +++++++++++------- spec/mailers/notification_mailer_spec.rb | 58 ++--- spec/mailers/user_mailer_spec.rb | 54 +++-- .../send_notifications.html.haml_spec.rb | 2 + 45 files changed, 248 insertions(+), 183 deletions(-) diff --git a/app/mailers/api_token_mailer.rb b/app/mailers/api_token_mailer.rb index 5f0c86d60..0ab3f6dea 100644 --- a/app/mailers/api_token_mailer.rb +++ b/app/mailers/api_token_mailer.rb @@ -7,7 +7,7 @@ class APITokenMailer < ApplicationMailer def expiration(api_token) @api_token = api_token user = api_token.administrateur.user - subject = "Votre jeton d'accès à la plateforme #{APPLICATION_NAME} expire le #{l(@api_token.expires_at, format: :long)}" + subject = "Votre jeton d'accès à la plateforme #{Current.application_name} expire le #{l(@api_token.expires_at, format: :long)}" mail(to: user.email, subject:) end diff --git a/app/mailers/concerns/mailer_defaults_configurable_concern.rb b/app/mailers/concerns/mailer_defaults_configurable_concern.rb index 21310ff7c..8ab29d33f 100644 --- a/app/mailers/concerns/mailer_defaults_configurable_concern.rb +++ b/app/mailers/concerns/mailer_defaults_configurable_concern.rb @@ -26,7 +26,8 @@ module MailerDefaultsConfigurableConcern included do before_action -> { self.class.save_original_defaults } - after_action -> { self.class.reset_original_defaults } + before_action :set_currents_for_legacy + after_action -> { self.class.reset_original_defaults } def configure_defaults_for_user(user) return if !user.is_a?(User) # not for super-admins diff --git a/app/mailers/instructeur_mailer.rb b/app/mailers/instructeur_mailer.rb index c51452b18..f2d4f6239 100644 --- a/app/mailers/instructeur_mailer.rb +++ b/app/mailers/instructeur_mailer.rb @@ -32,7 +32,7 @@ class InstructeurMailer < ApplicationMailer def send_login_token(instructeur, login_token) @instructeur_id = instructeur.id @login_token = login_token - subject = "Connexion sécurisée à #{APPLICATION_NAME}" + subject = "Connexion sécurisée à #{Current.application_name}" mail(to: instructeur.email, subject: subject) end diff --git a/app/mailers/preactivate_users_mailer.rb b/app/mailers/preactivate_users_mailer.rb index d53555218..d957b2fba 100644 --- a/app/mailers/preactivate_users_mailer.rb +++ b/app/mailers/preactivate_users_mailer.rb @@ -2,19 +2,19 @@ class PreactivateUsersMailer < ApplicationMailer layout 'mailers/layout' def reinvite(model, model_name) - subject = "Votre compte #{model_name} est activé sur #{APPLICATION_NAME}" + subject = "Votre compte #{model_name} est activé sur #{Current.application_name}" signature_separator = "-- " body = <<~END_OF_MAIL Bonjour, - les activations de compte #{model_name} sur #{APPLICATION_NAME} + les activations de compte #{model_name} sur #{Current.application_name} ont connu depuis deux semaines un fonctionnement erratique, et nous - pensons que votre inscription sur #{APPLICATION_NAME} a pu s’en + pensons que votre inscription sur #{Current.application_name} a pu s’en trouver affectée. Nous avons maintenant rétabli un fonctionnement normal de l’activation des comptes. Vous pouvez désormais vous connecter sans encombres à votre - compte #{model_name} sur #{APPLICATION_NAME}. + compte #{model_name} sur #{Current.application_name}. Si toutefois des difficultés devaient persister, n’hésitez pas à nous en faire part. @@ -22,7 +22,7 @@ class PreactivateUsersMailer < ApplicationMailer Cordialement #{signature_separator} - L’équipe #{APPLICATION_NAME} + L’équipe #{Current.application_name} END_OF_MAIL mail(to: model.email, diff --git a/app/mailers/resend_attestation_mailer.rb b/app/mailers/resend_attestation_mailer.rb index c67fcd3b8..395eb8062 100644 --- a/app/mailers/resend_attestation_mailer.rb +++ b/app/mailers/resend_attestation_mailer.rb @@ -25,7 +25,7 @@ class ResendAttestationMailer < ApplicationMailer Cordialement, - L’équipe #{APPLICATION_NAME} + L’équipe #{Current.application_name} HEREDOC end end diff --git a/app/views/administrateur_mailer/activate_before_expiration.haml b/app/views/administrateur_mailer/activate_before_expiration.haml index 3b6248022..ffaa8f74b 100644 --- a/app/views/administrateur_mailer/activate_before_expiration.haml +++ b/app/views/administrateur_mailer/activate_before_expiration.haml @@ -4,7 +4,7 @@ Bonjour, %p - Vous avez fait la demande d’un compte administrateur sur #{APPLICATION_NAME}. + Vous avez fait la demande d’un compte administrateur sur #{Current.application_name}. Votre compte a été créé mais reste inactif, il arrivera à expiration le #{try_format_date(@expiration_date)} %p diff --git a/app/views/administrateur_mailer/notify_procedure_expires_when_termine_forced.haml b/app/views/administrateur_mailer/notify_procedure_expires_when_termine_forced.haml index 95ef2a3ef..c8d6bbee5 100644 --- a/app/views/administrateur_mailer/notify_procedure_expires_when_termine_forced.haml +++ b/app/views/administrateur_mailer/notify_procedure_expires_when_termine_forced.haml @@ -7,7 +7,7 @@ Le règlement général sur la protection des données (RGPD) responsabilise les organismes publics et privés qui traitent leurs données. %p - Dans le cadre du respect du RGPD, nous (la plateforme #{APPLICATION_NAME}) venons d'activer la suppression automatique des dossiers sur la démarche : "#{@procedure.libelle}". + Dans le cadre du respect du RGPD, nous (la plateforme #{Current.application_name}) venons d'activer la suppression automatique des dossiers sur la démarche : "#{@procedure.libelle}". %p Vous pouvez d’ores et déjà archiver ces données en accédant à diff --git a/app/views/administrateur_mailer/notify_service_without_siret.haml b/app/views/administrateur_mailer/notify_service_without_siret.haml index 9312f14d8..495273644 100644 --- a/app/views/administrateur_mailer/notify_service_without_siret.haml +++ b/app/views/administrateur_mailer/notify_service_without_siret.haml @@ -5,7 +5,7 @@ %p Vous êtes administrateur sur la plateforme - = APPLICATION_NAME + = Current.application_name et au moins un de vos services n'a pas son siret renseigné. %p diff --git a/app/views/administration_mailer/new_admin_email.html.haml b/app/views/administration_mailer/new_admin_email.html.haml index 9328d4704..2dbe4273d 100644 --- a/app/views/administration_mailer/new_admin_email.html.haml +++ b/app/views/administration_mailer/new_admin_email.html.haml @@ -1,5 +1,5 @@ %p - Un nouvel administrateur a été créé sur #{APPLICATION_NAME}. + Un nouvel administrateur a été créé sur #{Current.application_name}. %ul %li diff --git a/app/views/administration_mailer/refuse_admin.html.haml b/app/views/administration_mailer/refuse_admin.html.haml index 94e688c9c..df244e2c9 100644 --- a/app/views/administration_mailer/refuse_admin.html.haml +++ b/app/views/administration_mailer/refuse_admin.html.haml @@ -8,10 +8,10 @@ %p - Pour les usagers ou les administrations publiques (collectivités, etc.) qui souhaitent remplir une démarche ou déposer un dossier en ligne, l’entrée dans #{APPLICATION_NAME} se fait via un lien fourni par l’administration responsable, sur son propre site web. Ce lien vous permettra de créer un compte et de remplir le formulaire dans la foulée. + Pour les usagers ou les administrations publiques (collectivités, etc.) qui souhaitent remplir une démarche ou déposer un dossier en ligne, l’entrée dans #{Current.application_name} se fait via un lien fourni par l’administration responsable, sur son propre site web. Ce lien vous permettra de créer un compte et de remplir le formulaire dans la foulée. %p - Si par contre vous rencontrez des problèmes lors de l'utilisation de #{APPLICATION_NAME} en tant qu'usager, merci d’expliciter le problème rencontré sur notre + Si par contre vous rencontrez des problèmes lors de l'utilisation de #{Current.application_name} en tant qu'usager, merci d’expliciter le problème rencontré sur notre = link_to("formulaire de contact", contact_url) \. diff --git a/app/views/api_token_mailer/expiration.html.haml b/app/views/api_token_mailer/expiration.html.haml index e645c4966..4635f4cc2 100644 --- a/app/views/api_token_mailer/expiration.html.haml +++ b/app/views/api_token_mailer/expiration.html.haml @@ -8,7 +8,7 @@ %p %strong Ce jeton expirera le #{l(@api_token.expires_at, format: :long)}. %br - L'accès à l'API de #{APPLICATION_NAME} sera alors bloqué pour ce jeton. + L'accès à l'API de #{Current.application_name} sera alors bloqué pour ce jeton. %p Pour le renouveler, rendez-vous sur votre page de profil, dans la section « Jetons d’identification de l’API » : diff --git a/app/views/avis_mailer/avis_invitation.html.haml b/app/views/avis_mailer/avis_invitation.html.haml index a4a6dafc0..e4bb0db96 100644 --- a/app/views/avis_mailer/avis_invitation.html.haml +++ b/app/views/avis_mailer/avis_invitation.html.haml @@ -2,7 +2,7 @@ - content_for(:footer) do Merci de ne pas répondre à cet email. Donnez votre avis - = link_to("sur #{APPLICATION_NAME}", @url) + = link_to("sur #{Current.application_name}", @url) ou = succeed '.' do = mail_to(@avis.claimant.email, "contactez la personne qui vous a invité") diff --git a/app/views/devise_mailer/confirmation_instructions.en.html.haml b/app/views/devise_mailer/confirmation_instructions.en.html.haml index 7f5d3c3db..39ef81aee 100644 --- a/app/views/devise_mailer/confirmation_instructions.en.html.haml +++ b/app/views/devise_mailer/confirmation_instructions.en.html.haml @@ -5,7 +5,7 @@ %p= t(:hello, scope: [:views, :shared, :greetings]) %p - You have entered your details to create an account on #{APPLICATION_NAME}. To confirm your email and finish creating your account, select the following link: + You have entered your details to create an account on #{Current.application_name}. To confirm your email and finish creating your account, select the following link: - link = confirmation_url(@user, confirmation_token: @token, procedure_id: @procedure&.id) = link_to(link, link) @@ -15,7 +15,7 @@ %p= t(:hello, scope: [:views, :shared, :greetings]) %p - To confirm your account email change on #{APPLICATION_NAME}, select the following link: + To confirm your account email change on #{Current.application_name}, select the following link: = link_to(confirmation_url(@user, confirmation_token: @token), confirmation_url(@user, confirmation_token: @token)) = render partial: "layouts/mailers/signature" diff --git a/app/views/devise_mailer/confirmation_instructions.html.haml b/app/views/devise_mailer/confirmation_instructions.html.haml index ba4904207..6f4c4a50c 100644 --- a/app/views/devise_mailer/confirmation_instructions.html.haml +++ b/app/views/devise_mailer/confirmation_instructions.html.haml @@ -5,7 +5,7 @@ %p= t(:hello, scope: [:views, :shared, :greetings]) %p - Pour activer votre compte sur #{APPLICATION_NAME}, veuillez cliquer sur le lien suivant : + Pour activer votre compte sur #{Current.application_name}, veuillez cliquer sur le lien suivant : - link = confirmation_url(@user, confirmation_token: @token, procedure_id: @procedure&.id, prefill_token: @prefill_token) = link_to(link, link) diff --git a/app/views/devise_mailer/email_changed.en.html.haml b/app/views/devise_mailer/email_changed.en.html.haml index 4371b4709..484edc54e 100644 --- a/app/views/devise_mailer/email_changed.en.html.haml +++ b/app/views/devise_mailer/email_changed.en.html.haml @@ -5,9 +5,9 @@ - unconfirmed_email = @resource.try(:unconfirmed_email?) - if unconfirmed_email.present? %p - We recieved a request to change the email address associated with your account #{@email} on #{APPLICATION_NAME}. The new email address will be #{unconfirmed_email}. + We recieved a request to change the email address associated with your account #{@email} on #{Current.application_name}. The new email address will be #{unconfirmed_email}. - else %p - A change to the email address associated with your account #{@email} was made on #{APPLICATION_NAME}. You can now connect with the email address #{@resource.email}. + A change to the email address associated with your account #{@email} was made on #{Current.application_name}. You can now connect with the email address #{@resource.email}. = render partial: "layouts/mailers/signature" diff --git a/app/views/devise_mailer/email_changed.html.haml b/app/views/devise_mailer/email_changed.html.haml index 04fc96449..7fc9234c4 100644 --- a/app/views/devise_mailer/email_changed.html.haml +++ b/app/views/devise_mailer/email_changed.html.haml @@ -6,13 +6,13 @@ - if unconfirmed_email.present? %p Nous avons reçu une demande de changement d’adresse email pour votre - compte #{@email} sur #{APPLICATION_NAME}. + compte #{@email} sur #{Current.application_name}. Une fois la demande prise en compte, la nouvelle adresse email de votre compte sera #{unconfirmed_email}. - else %p Le changement d’adresse email de votre compte #{@email} sur - #{APPLICATION_NAME} a bien été pris en compte. + #{Current.application_name} a bien été pris en compte. Vous pouvez désormais vous connecter avec l’adresse #{@resource.email}. = render partial: "layouts/mailers/signature" diff --git a/app/views/devise_mailer/password_change.en.html.haml b/app/views/devise_mailer/password_change.en.html.haml index 3f5acd006..6e3977b9a 100644 --- a/app/views/devise_mailer/password_change.en.html.haml +++ b/app/views/devise_mailer/password_change.en.html.haml @@ -3,6 +3,6 @@ %p= t(:hello, scope: [:views, :shared, :greetings]) %p - A request to change your password on #{APPLICATION_NAME} for the account #{@resource.email} was successfully processed. + A request to change your password on #{Current.application_name} for the account #{@resource.email} was successfully processed. = render partial: "layouts/mailers/signature" diff --git a/app/views/devise_mailer/password_change.html.haml b/app/views/devise_mailer/password_change.html.haml index 56403e9fd..d79ae83a9 100644 --- a/app/views/devise_mailer/password_change.html.haml +++ b/app/views/devise_mailer/password_change.html.haml @@ -4,6 +4,6 @@ %p La demande de changement de mot de passe pour votre compte #{@resource.email} sur - #{APPLICATION_NAME} a bien été prise en compte. + #{Current.application_name} a bien été prise en compte. = render partial: "layouts/mailers/signature" diff --git a/app/views/devise_mailer/reset_password_instructions.en.html.haml b/app/views/devise_mailer/reset_password_instructions.en.html.haml index d5eb8744a..87210101f 100644 --- a/app/views/devise_mailer/reset_password_instructions.en.html.haml +++ b/app/views/devise_mailer/reset_password_instructions.en.html.haml @@ -1,7 +1,7 @@ %p= t(:hello, scope: [:views, :shared, :greetings]) %p - Someone has requested to change your account password on #{APPLICATION_NAME}. To define a new password, select the following link: + Someone has requested to change your account password on #{Current.application_name}. To define a new password, select the following link: = round_button 'Change the password', edit_password_url(@resource, reset_password_token: @token), :primary diff --git a/app/views/devise_mailer/reset_password_instructions.html.haml b/app/views/devise_mailer/reset_password_instructions.html.haml index bf6a82e5f..f3f1937b3 100644 --- a/app/views/devise_mailer/reset_password_instructions.html.haml +++ b/app/views/devise_mailer/reset_password_instructions.html.haml @@ -1,7 +1,7 @@ %p= t(:hello, scope: [:views, :shared, :greetings]) %p - Vous avez demandé à changer votre mot de passe sur #{APPLICATION_NAME}. Pour ceci, merci de cliquer sur le lien suivant : + Vous avez demandé à changer votre mot de passe sur #{Current.application_name}. Pour ceci, merci de cliquer sur le lien suivant : = round_button 'Changer mon mot de passe', edit_password_url(@resource, reset_password_token: @token), :primary diff --git a/app/views/devise_mailer/unlock_instructions.en.html.haml b/app/views/devise_mailer/unlock_instructions.en.html.haml index acdde6627..6eabbe623 100644 --- a/app/views/devise_mailer/unlock_instructions.en.html.haml +++ b/app/views/devise_mailer/unlock_instructions.en.html.haml @@ -3,7 +3,7 @@ %p= t(:hello, scope: [:views, :shared, :greetings]) %p - Someone made too many unsuccessful attempts to connect to your account #{@resource.email} on #{APPLICATION_NAME}. + Someone made too many unsuccessful attempts to connect to your account #{@resource.email} on #{Current.application_name}. As a security measure, we temporarily locked access to your account. %p diff --git a/app/views/devise_mailer/unlock_instructions.html.haml b/app/views/devise_mailer/unlock_instructions.html.haml index 3fa534fc4..e7cf287c7 100644 --- a/app/views/devise_mailer/unlock_instructions.html.haml +++ b/app/views/devise_mailer/unlock_instructions.html.haml @@ -4,7 +4,7 @@ %p Quelqu’un a tenté de se connecter un grand nombre de fois sans succès à votre - compte #{@resource.email} sur #{APPLICATION_NAME}. Par mesure de précaution, + compte #{@resource.email} sur #{Current.application_name}. Par mesure de précaution, nous avons temporairement désactivé l’accès à votre compte. %p diff --git a/app/views/groupe_gestionnaire_mailer/notify_added_administrateurs.html.haml b/app/views/groupe_gestionnaire_mailer/notify_added_administrateurs.html.haml index 94f82e361..79eef8c81 100644 --- a/app/views/groupe_gestionnaire_mailer/notify_added_administrateurs.html.haml +++ b/app/views/groupe_gestionnaire_mailer/notify_added_administrateurs.html.haml @@ -1,6 +1,6 @@ %p= t(:hello, scope: [:views, :shared, :greetings]) %p - = t(".email_body", groupe_gestionnaire_name: @groupe_gestionnaire.name, email: @current_super_admin_email, application_name: APPLICATION_NAME) + = t(".email_body", groupe_gestionnaire_name: @groupe_gestionnaire.name, email: @current_super_admin_email, application_name: Current.application_name) = render partial: "layouts/mailers/signature" diff --git a/app/views/groupe_gestionnaire_mailer/notify_added_gestionnaires.html.haml b/app/views/groupe_gestionnaire_mailer/notify_added_gestionnaires.html.haml index 94f82e361..79eef8c81 100644 --- a/app/views/groupe_gestionnaire_mailer/notify_added_gestionnaires.html.haml +++ b/app/views/groupe_gestionnaire_mailer/notify_added_gestionnaires.html.haml @@ -1,6 +1,6 @@ %p= t(:hello, scope: [:views, :shared, :greetings]) %p - = t(".email_body", groupe_gestionnaire_name: @groupe_gestionnaire.name, email: @current_super_admin_email, application_name: APPLICATION_NAME) + = t(".email_body", groupe_gestionnaire_name: @groupe_gestionnaire.name, email: @current_super_admin_email, application_name: Current.application_name) = render partial: "layouts/mailers/signature" diff --git a/app/views/groupe_gestionnaire_mailer/notify_removed_administrateur.html.haml b/app/views/groupe_gestionnaire_mailer/notify_removed_administrateur.html.haml index 94f82e361..79eef8c81 100644 --- a/app/views/groupe_gestionnaire_mailer/notify_removed_administrateur.html.haml +++ b/app/views/groupe_gestionnaire_mailer/notify_removed_administrateur.html.haml @@ -1,6 +1,6 @@ %p= t(:hello, scope: [:views, :shared, :greetings]) %p - = t(".email_body", groupe_gestionnaire_name: @groupe_gestionnaire.name, email: @current_super_admin_email, application_name: APPLICATION_NAME) + = t(".email_body", groupe_gestionnaire_name: @groupe_gestionnaire.name, email: @current_super_admin_email, application_name: Current.application_name) = render partial: "layouts/mailers/signature" diff --git a/app/views/groupe_gestionnaire_mailer/notify_removed_gestionnaire.html.haml b/app/views/groupe_gestionnaire_mailer/notify_removed_gestionnaire.html.haml index 94f82e361..79eef8c81 100644 --- a/app/views/groupe_gestionnaire_mailer/notify_removed_gestionnaire.html.haml +++ b/app/views/groupe_gestionnaire_mailer/notify_removed_gestionnaire.html.haml @@ -1,6 +1,6 @@ %p= t(:hello, scope: [:views, :shared, :greetings]) %p - = t(".email_body", groupe_gestionnaire_name: @groupe_gestionnaire.name, email: @current_super_admin_email, application_name: APPLICATION_NAME) + = t(".email_body", groupe_gestionnaire_name: @groupe_gestionnaire.name, email: @current_super_admin_email, application_name: Current.application_name) = render partial: "layouts/mailers/signature" diff --git a/app/views/instructeur_mailer/send_login_token.html.haml b/app/views/instructeur_mailer/send_login_token.html.haml index 135401c5f..47fe1d2bb 100644 --- a/app/views/instructeur_mailer/send_login_token.html.haml +++ b/app/views/instructeur_mailer/send_login_token.html.haml @@ -2,7 +2,7 @@ Bonjour, %p - Veuillez cliquer sur le lien sécurisé suivant pour vous connecter à #{APPLICATION_NAME} :  + Veuillez cliquer sur le lien sécurisé suivant pour vous connecter à #{Current.application_name} :  = link_to(sign_in_by_link_url(@instructeur_id, jeton: @login_token), sign_in_by_link_url(@instructeur_id, jeton: @login_token)) %p diff --git a/app/views/instructeur_mailer/send_notifications.html.haml b/app/views/instructeur_mailer/send_notifications.html.haml index 4b801e9f0..7a872ed3c 100644 --- a/app/views/instructeur_mailer/send_notifications.html.haml +++ b/app/views/instructeur_mailer/send_notifications.html.haml @@ -4,7 +4,7 @@ Bonjour, %p - Vous avez du nouveau sur #{APPLICATION_NAME} depuis + Vous avez du nouveau sur #{Current.application_name} depuis = Date.today.monday? ? "vendredi dernier" : "hier" %ul diff --git a/app/views/instructeur_mailer/user_to_instructeur.html.haml b/app/views/instructeur_mailer/user_to_instructeur.html.haml index 0371661e1..ca564c755 100644 --- a/app/views/instructeur_mailer/user_to_instructeur.html.haml +++ b/app/views/instructeur_mailer/user_to_instructeur.html.haml @@ -2,7 +2,7 @@ Bonjour, %p - Vous venez d’être nommé instructeur sur #{APPLICATION_NAME}. + Vous venez d’être nommé instructeur sur #{Current.application_name}. = "Votre compte (#{@email}) vous donnera désormais aussi accès à l’espace instructeur." = render partial: "layouts/mailers/signature" diff --git a/app/views/invite_mailer/invite_guest.html.haml b/app/views/invite_mailer/invite_guest.html.haml index eb9ba27d2..8b65443be 100644 --- a/app/views/invite_mailer/invite_guest.html.haml +++ b/app/views/invite_mailer/invite_guest.html.haml @@ -6,7 +6,7 @@ = @invite.email_sender souhaite que vous participiez à l’élaboration d’un dossier pour la démarche %strong= @invite.dossier.procedure.libelle - sur #{APPLICATION_NAME}. + sur #{Current.application_name}. - if @invite.message.present? %blockquote diff --git a/app/views/invite_mailer/invite_user.html.haml b/app/views/invite_mailer/invite_user.html.haml index abce7aafd..bc856166e 100644 --- a/app/views/invite_mailer/invite_user.html.haml +++ b/app/views/invite_mailer/invite_user.html.haml @@ -4,7 +4,7 @@ %p L’utilisateur = @invite.email_sender - souhaite que vous participiez à l'élaboration d’un dossier sur #{APPLICATION_NAME}. + souhaite que vous participiez à l'élaboration d’un dossier sur #{Current.application_name}. - if @invite.message.present? %blockquote diff --git a/app/views/layouts/mailers/_bizdev_signature.html.haml b/app/views/layouts/mailers/_bizdev_signature.html.haml index 95c6ce6c6..c5cfc2108 100644 --- a/app/views/layouts/mailers/_bizdev_signature.html.haml +++ b/app/views/layouts/mailers/_bizdev_signature.html.haml @@ -4,7 +4,7 @@ Cordialement, = author_name %br %br -Équipe #{APPLICATION_NAME} +Équipe #{Current.application_name} %br Téléphone (standard) : = CONTACT_PHONE diff --git a/app/views/layouts/mailers/_commentaire_groupe_gestionnaire_footer.html.haml b/app/views/layouts/mailers/_commentaire_groupe_gestionnaire_footer.html.haml index 39c36de80..d5558423f 100644 --- a/app/views/layouts/mailers/_commentaire_groupe_gestionnaire_footer.html.haml +++ b/app/views/layouts/mailers/_commentaire_groupe_gestionnaire_footer.html.haml @@ -1,2 +1,2 @@ %strong - = t('.do_not_reply_html', application_name: APPLICATION_NAME, sender_email: @sender_email) + = t('.do_not_reply_html', application_name: Current.application_name, sender_email: @sender_email) diff --git a/app/views/layouts/mailers/_signature.html.haml b/app/views/layouts/mailers/_signature.html.haml index 69d2a64dd..d87b4ead1 100644 --- a/app/views/layouts/mailers/_signature.html.haml +++ b/app/views/layouts/mailers/_signature.html.haml @@ -6,4 +6,4 @@ - else -# The WORD JOINER unicode entity (⁠) prevents email clients from auto-linking the signature = t('.team') - #{APPLICATION_NAME.gsub(".","⁠.").html_safe} + #{Current.application_name.gsub(".","⁠.").html_safe} diff --git a/app/views/layouts/mailers/layout.html.erb b/app/views/layouts/mailers/layout.html.erb index a9fcb50c4..0fb74b8f5 100644 --- a/app/views/layouts/mailers/layout.html.erb +++ b/app/views/layouts/mailers/layout.html.erb @@ -50,7 +50,7 @@
- Logo <%= " src="<%= image_url("#{MAILER_LOGO_SRC}") %>" style="max-width=600px; padding=30px 0; display=inline !important; vertical-align=bottom; border=0; height=auto; outline=none; text-decoration=none; -ms-interpolation-mode=bicubic;" /> + Logo <%= " src="<%= image_url("#{MAILER_LOGO_SRC}") %>" style="max-width=600px; padding=30px 0; display=inline !important; vertical-align=bottom; border=0; height=auto; outline=none; text-decoration=none; -ms-interpolation-mode=bicubic;" />
@@ -168,7 +168,7 @@
- Logo <%= " src="<%= image_url("#{MAILER_FOOTER_LOGO_SRC}") %>" style="max-width=125px; padding=30px 0; display=inline !important; vertical-align=bottom; border=0; height=auto; outline=none; text-decoration=none; -ms-interpolation-mode=bicubic;" /> + Logo <%= " src="<%= image_url("#{MAILER_FOOTER_LOGO_SRC}") %>" style="max-width=125px; padding=30px 0; display=inline !important; vertical-align=bottom; border=0; height=auto; outline=none; text-decoration=none; -ms-interpolation-mode=bicubic;" />
diff --git a/app/views/layouts/mailers/notifications_layout.html.erb b/app/views/layouts/mailers/notifications_layout.html.erb index 6766b744d..8ac423da8 100644 --- a/app/views/layouts/mailers/notifications_layout.html.erb +++ b/app/views/layouts/mailers/notifications_layout.html.erb @@ -145,7 +145,7 @@
- <%= "#{APPLICATION_NAME}" %> est un service fourni par <%= t("links.provider.provided_by") %> + <%= "#{Current.application_name}" %> est un service fourni par <%= t("links.provider.provided_by") %>
diff --git a/app/views/notification_mailer/send_notification_for_tiers.html.haml b/app/views/notification_mailer/send_notification_for_tiers.html.haml index 3365bb949..75306e99b 100644 --- a/app/views/notification_mailer/send_notification_for_tiers.html.haml +++ b/app/views/notification_mailer/send_notification_for_tiers.html.haml @@ -26,4 +26,4 @@ = t(:best_regards, scope: [:views, :shared, :greetings]) %br = t('layouts.mailers.signature.team') - #{APPLICATION_NAME.gsub(".","⁠.").html_safe} + #{Current.application_name.gsub(".","⁠.").html_safe} diff --git a/app/views/user_mailer/invite_gestionnaire.html.haml b/app/views/user_mailer/invite_gestionnaire.html.haml index 267f2add4..a01de92d5 100644 --- a/app/views/user_mailer/invite_gestionnaire.html.haml +++ b/app/views/user_mailer/invite_gestionnaire.html.haml @@ -4,7 +4,7 @@ Bonjour, %p - Vous venez d’être nommé gestionnaire du groupe gestionnaire #{@groupe_gestionnaire.name} sur #{APPLICATION_NAME}. + Vous venez d’être nommé gestionnaire du groupe gestionnaire #{@groupe_gestionnaire.name} sur #{Current.application_name}. %p Votre compte a été créé pour l'adresse email #{@user.email}. Pour l’activer, nous vous invitons à cliquer sur le lien suivant :  diff --git a/app/views/user_mailer/invite_instructeur.html.haml b/app/views/user_mailer/invite_instructeur.html.haml index 6146e11ed..b7ba5b9e8 100644 --- a/app/views/user_mailer/invite_instructeur.html.haml +++ b/app/views/user_mailer/invite_instructeur.html.haml @@ -4,7 +4,7 @@ Bonjour, %p - Vous venez d’être nommé instructeur sur #{APPLICATION_NAME}. + Vous venez d’être nommé instructeur sur #{Current.application_name}. %p Votre compte a été créé pour l'adresse email @@ -15,7 +15,7 @@ = link_to(users_activate_url(token: @reset_password_token), users_activate_url(token: @reset_password_token)) %p - Lors de vos prochaines connexions sur #{APPLICATION_NAME} cliquez sur le bouton « Se connecter » positionné sur le haut de page ou bien sur ce lien :  + Lors de vos prochaines connexions sur #{Current.application_name} cliquez sur le bouton « Se connecter » positionné sur le haut de page ou bien sur ce lien :  = link_to new_user_session_url, new_user_session_url - if AgentConnectService.enabled? diff --git a/app/views/user_mailer/new_account_warning.html.haml b/app/views/user_mailer/new_account_warning.html.haml index 5f479b14e..6614001a3 100644 --- a/app/views/user_mailer/new_account_warning.html.haml +++ b/app/views/user_mailer/new_account_warning.html.haml @@ -4,7 +4,7 @@ Bonjour, %p - Une demande de création de compte a été réalisée sur le site #{APPLICATION_NAME} pour l'email #{@user.email}. + Une demande de création de compte a été réalisée sur le site #{Current.application_name} pour l'email #{@user.email}. %p %strong Votre compte existe déjà. diff --git a/app/views/user_mailer/notify_inactive_close_to_deletion.html.haml b/app/views/user_mailer/notify_inactive_close_to_deletion.html.haml index 3fdb4efbe..8b8ca4e5b 100644 --- a/app/views/user_mailer/notify_inactive_close_to_deletion.html.haml +++ b/app/views/user_mailer/notify_inactive_close_to_deletion.html.haml @@ -4,7 +4,7 @@ Bonjour, %p - Cela fait plus de deux ans que vous ne vous êtes pas connecté à #{APPLICATION_NAME}. + Cela fait plus de deux ans que vous ne vous êtes pas connecté à #{Current.application_name}. - if @user.dossiers.not_brouillon.count == 0 Aussi vous n'avez plus de dossier sur la plateforme. diff --git a/spec/mailers/dossier_mailer_spec.rb b/spec/mailers/dossier_mailer_spec.rb index ebc951c88..c018b7df1 100644 --- a/spec/mailers/dossier_mailer_spec.rb +++ b/spec/mailers/dossier_mailer_spec.rb @@ -17,19 +17,21 @@ RSpec.describe DossierMailer, type: :mailer do subject { described_class.with(dossier:).notify_new_draft } - it { expect(subject.subject).to include("brouillon") } - it { expect(subject.subject).to include(dossier.procedure.libelle) } - it { expect(subject.body).to include(dossier.procedure.libelle) } - it { expect(subject.body).to include(dossier_url(dossier, host: ENV.fetch("APP_HOST_LEGACY"))) } - it { expect(subject.body).to include("Vous pouvez déposer votre dossier jusqu’au") } - it { expect(subject.body).to include("heure de") } + it 'includes the correct subject and body content' do + expect(subject.subject).to include("brouillon") + expect(subject.subject).to include(dossier.procedure.libelle) + expect(subject.body).to include(dossier.procedure.libelle) + expect(subject.body).to include(dossier_url(dossier, host: ENV.fetch("APP_HOST_LEGACY"))) + expect(subject.body).to include("Vous pouvez déposer votre dossier jusqu’au") + expect(subject.body).to include("heure de") + end it_behaves_like 'a dossier notification' - context "user prefers new domain" do + context "when user prefers new domain" do let(:user) { create(:user, preferred_domain: :demarches_gouv_fr) } - it do + it 'includes the correct body content and sender email' do expect(subject.body).to include(dossier_url(dossier, host: ENV.fetch('APP_HOST'))) expect(header_value("From", subject)).to include("ne-pas-repondre@demarches.gouv.fr") end @@ -43,10 +45,12 @@ RSpec.describe DossierMailer, type: :mailer do let(:commentaire) { create(:commentaire, dossier: dossier) } subject { described_class.with(commentaire: commentaire).notify_new_answer } - it { expect(subject.subject).to include("Nouveau message") } - it { expect(subject.subject).to include(dossier.id.to_s) } - it { expect(subject.body).to include(dossier.procedure.service.email) } - it { expect(subject.body).not_to include(messagerie_dossier_url(dossier, host: ENV.fetch("APP_HOST_LEGACY"))) } + it 'checks email subject and body for correct inclusions and exclusions' do + expect(subject.subject).to include("Nouveau message") + expect(subject.subject).to include(dossier.id.to_s) + expect(subject.body).to include(dossier.procedure.service.email) + expect(subject.body).not_to include(messagerie_dossier_url(dossier, host: ENV.fetch("APP_HOST_LEGACY"))) + end it_behaves_like 'a dossier notification' @@ -62,9 +66,11 @@ RSpec.describe DossierMailer, type: :mailer do subject { described_class.with(commentaire: commentaire).notify_new_answer } - it { expect(subject.subject).to include("Nouveau message") } - it { expect(subject.subject).to include(dossier.id.to_s) } - it { expect(subject.body).to include(messagerie_dossier_url(dossier, host: ENV.fetch("APP_HOST_LEGACY"))) } + it 'checks email subject and body for correct inclusions' do + expect(subject.subject).to include("Nouveau message") + expect(subject.subject).to include(dossier.id.to_s) + expect(subject.body).to include(messagerie_dossier_url(dossier, host: ENV.fetch("APP_HOST_LEGACY"))) + end it_behaves_like 'a dossier notification' end @@ -90,10 +96,12 @@ RSpec.describe DossierMailer, type: :mailer do subject { described_class.notify_deletion_to_administration(deleted_dossier, to_email) } - it { expect(subject.subject).to eq("Le dossier nº #{deleted_dossier.dossier_id} a été supprimé à la demande de l’usager") } - it { expect(subject.body).to include("À la demande de l’usager") } - it { expect(subject.body).to include(deleted_dossier.dossier_id) } - it { expect(subject.body).to include(deleted_dossier.procedure.libelle) } + it 'verifies subject and body content for deletion notification' do + expect(subject.subject).to eq("Le dossier nº #{deleted_dossier.dossier_id} a été supprimé à la demande de l’usager") + expect(subject.body).to include("À la demande de l’usager") + expect(subject.body).to include(deleted_dossier.dossier_id) + expect(subject.body).to include(deleted_dossier.procedure.libelle) + end end describe '.notify_brouillon_near_deletion' do @@ -101,8 +109,10 @@ RSpec.describe DossierMailer, type: :mailer do subject { described_class.notify_brouillon_near_deletion([dossier], dossier.user.email) } - it { expect(subject.body).to include("n° #{dossier.id} ") } - it { expect(subject.body).to include(dossier.procedure.libelle) } + it 'checks email body for correct inclusions regarding brouillon nearing deletion' do + expect(subject.body).to include("n° #{dossier.id} ") + expect(subject.body).to include(dossier.procedure.libelle) + end end describe '.notify_brouillon_deletion' do @@ -110,8 +120,10 @@ RSpec.describe DossierMailer, type: :mailer do subject { described_class.notify_brouillon_deletion([dossier.hash_for_deletion_mail], dossier.user.email) } - it { expect(subject.subject).to eq("Un dossier en brouillon a été supprimé automatiquement") } - it { expect(subject.body).to include("n° #{dossier.id} (#{dossier.procedure.libelle})") } + it 'verifies subject and body content for brouillon deletion notification' do + expect(subject.subject).to eq("Un dossier en brouillon a été supprimé automatiquement") + expect(subject.body).to include("n° #{dossier.id} (#{dossier.procedure.libelle})") + end end describe '.notify_automatic_deletion_to_user' do @@ -122,11 +134,13 @@ RSpec.describe DossierMailer, type: :mailer do subject { described_class.notify_automatic_deletion_to_user([deleted_dossier], dossier.user.email) } - it { expect(subject.to).to eq([dossier.user.email]) } - it { expect(subject.subject).to eq("Un dossier a été supprimé automatiquement de votre compte") } - it { expect(subject.body).to include("N° #{dossier.id} ") } - it { expect(subject.body).to include(dossier.procedure.libelle) } - it { expect(subject.body).to include("nous nous excusons de la gêne occasionnée") } + it 'checks email subject, to, and body for correct inclusions and exclusions for en_construction status' do + expect(subject.to).to eq([dossier.user.email]) + expect(subject.subject).to eq("Un dossier a été supprimé automatiquement de votre compte") + expect(subject.body).to include("N° #{dossier.id} ") + expect(subject.body).to include(dossier.procedure.libelle) + expect(subject.body).to include("nous nous excusons de la gêne occasionnée") + end end describe 'termine' do @@ -134,11 +148,13 @@ RSpec.describe DossierMailer, type: :mailer do subject { described_class.notify_automatic_deletion_to_user([deleted_dossier], dossier.user.email) } - it { expect(subject.to).to eq([dossier.user.email]) } - it { expect(subject.subject).to eq("Un dossier a été supprimé automatiquement de votre compte") } - it { expect(subject.body).to include("N° #{dossier.id} ") } - it { expect(subject.body).to include(dossier.procedure.libelle) } - it { expect(subject.body).not_to include("nous nous excusons de la gène occasionnée") } + it 'checks email subject, to, and body for correct inclusions and exclusions for termine status' do + expect(subject.to).to eq([dossier.user.email]) + expect(subject.subject).to eq("Un dossier a été supprimé automatiquement de votre compte") + expect(subject.body).to include("N° #{dossier.id} ") + expect(subject.body).to include(dossier.procedure.libelle) + expect(subject.body).not_to include("nous nous excusons de la gêne occasionnée") + end end end @@ -148,8 +164,10 @@ RSpec.describe DossierMailer, type: :mailer do subject { described_class.notify_automatic_deletion_to_administration([deleted_dossier], dossier.user.email) } - it { expect(subject.subject).to eq("Un dossier a été supprimé automatiquement") } - it { expect(subject.body).to include("n° #{dossier.id} (#{dossier.procedure.libelle})") } + it 'verifies subject and body content for automatic deletion notification' do + expect(subject.subject).to eq("Un dossier a été supprimé automatiquement") + expect(subject.body).to include("n° #{dossier.id} (#{dossier.procedure.libelle})") + end end describe '.notify_near_deletion_to_administration' do @@ -158,11 +176,13 @@ RSpec.describe DossierMailer, type: :mailer do subject { described_class.notify_near_deletion_to_administration([dossier], dossier.user.email) } - it { expect(subject.subject).to eq("Un dossier en construction va bientôt être supprimé") } - it { expect(subject.body).to include("N° #{dossier.id} ") } - it { expect(subject.body).to include(dossier.procedure.libelle) } - it { expect(subject.body).to include("PDF") } - it { expect(subject.body).to include("Vous avez 14 jours pour commencer l’instruction du dossier.") } + it 'checks email subject and body for correct inclusions for en_construction status' do + expect(subject.subject).to eq("Un dossier en construction va bientôt être supprimé") + expect(subject.body).to include("N° #{dossier.id} ") + expect(subject.body).to include(dossier.procedure.libelle) + expect(subject.body).to include("PDF") + expect(subject.body).to include("Vous avez 14 jours pour commencer l’instruction du dossier.") + end end describe 'termine' do @@ -170,9 +190,11 @@ RSpec.describe DossierMailer, type: :mailer do subject { described_class.notify_near_deletion_to_administration([dossier], dossier.user.email) } - it { expect(subject.subject).to eq("Un dossier dont le traitement est terminé va bientôt être supprimé") } - it { expect(subject.body).to include("N° #{dossier.id} ") } - it { expect(subject.body).to include(dossier.procedure.libelle) } + it 'verifies subject and body content for near deletion notification of completed cases' do + expect(subject.subject).to eq("Un dossier dont le traitement est terminé va bientôt être supprimé") + expect(subject.body).to include("N° #{dossier.id} ") + expect(subject.body).to include(dossier.procedure.libelle) + end end end @@ -182,12 +204,14 @@ RSpec.describe DossierMailer, type: :mailer do subject { described_class.notify_near_deletion_to_user([dossier], dossier.user.email) } - it { expect(subject.to).to eq([dossier.user.email]) } - it { expect(subject.subject).to eq("Un dossier en construction va bientôt être supprimé") } - it { expect(subject.body).to include("N° #{dossier.id} ") } - it { expect(subject.body).to include(dossier.procedure.libelle) } - it { expect(subject.body).to include("Votre compte reste activé") } - it { expect(subject.body).to include("Si vous souhaitez conserver votre dossier plus longtemps, vous pouvez prolonger sa durée de conservation dans l’interface.") } + it 'verifies email subject, to, and body for correct inclusions for en_construction status' do + expect(subject.to).to eq([dossier.user.email]) + expect(subject.subject).to eq("Un dossier en construction va bientôt être supprimé") + expect(subject.body).to include("N° #{dossier.id} ") + expect(subject.body).to include(dossier.procedure.libelle) + expect(subject.body).to include("Votre compte reste activé") + expect(subject.body).to include("Si vous souhaitez conserver votre dossier plus longtemps, vous pouvez prolonger sa durée de conservation dans l’interface.") + end end describe 'termine' do @@ -195,12 +219,14 @@ RSpec.describe DossierMailer, type: :mailer do subject { described_class.notify_near_deletion_to_user([dossier], dossier.user.email) } - it { expect(subject.to).to eq([dossier.user.email]) } - it { expect(subject.subject).to eq("Un dossier dont le traitement est terminé va bientôt être supprimé") } - it { expect(subject.body).to include("N° #{dossier.id} ") } - it { expect(subject.body).to include(dossier.procedure.libelle) } - it { expect(subject.body).to include("Votre compte reste activé") } - it { expect(subject.body).to include("PDF") } + it 'checks email subject, to, and body for correct inclusions for termine status' do + expect(subject.to).to eq([dossier.user.email]) + expect(subject.subject).to eq("Un dossier dont le traitement est terminé va bientôt être supprimé") + expect(subject.body).to include("N° #{dossier.id} ") + expect(subject.body).to include(dossier.procedure.libelle) + expect(subject.body).to include("Votre compte reste activé") + expect(subject.body).to include("PDF") + end end describe 'multiple termines' do @@ -208,10 +234,12 @@ RSpec.describe DossierMailer, type: :mailer do subject { described_class.notify_near_deletion_to_user(dossiers, dossiers[0].user.email) } - it { expect(subject.subject).to eq("Des dossiers dont le traitement est terminé vont bientôt être supprimés") } - it { expect(subject.body).to include("N° #{dossiers[0].id} ") } - it { expect(subject.body).to include("N° #{dossiers[1].id} ") } - it { expect(subject.body).to include("N° #{dossiers[2].id} ") } + it 'verifies email subject and body contain correct dossier numbers for multiple termine status' do + expect(subject.subject).to eq("Des dossiers dont le traitement est terminé vont bientôt être supprimés") + dossiers.each do |dossier| + expect(subject.body).to include("N° #{dossier.id} ") + end + end end end @@ -221,10 +249,12 @@ RSpec.describe DossierMailer, type: :mailer do subject { described_class.notify_groupe_instructeur_changed(instructeur, dossier) } - it { expect(subject.subject).to eq("Le dossier nº #{dossier.id} a changé de groupe d’instructeurs") } - it { expect(subject.body).to include("n° #{dossier.id}") } - it { expect(subject.body).to include(dossier.procedure.libelle) } - it { expect(subject.body).to include("Suite à cette modification, vous ne suivez plus ce dossier.") } + it 'verifies subject and body content for groupe instructeur change notification' do + expect(subject.subject).to eq("Le dossier nº #{dossier.id} a changé de groupe d’instructeurs") + expect(subject.body).to include("n° #{dossier.id}") + expect(subject.body).to include(dossier.procedure.libelle) + expect(subject.body).to include("Suite à cette modification, vous ne suivez plus ce dossier.") + end end describe '.notify_pending_correction' do @@ -240,19 +270,23 @@ RSpec.describe DossierMailer, type: :mailer do } context 'reason is incorrect' do - it { expect(subject.subject).to eq("Vous devez corriger votre dossier nº #{dossier.id} « #{dossier.procedure.libelle} »") } - it { expect(subject.body).to include("apporter des corrections") } - it { expect(subject.body).not_to include("Silence") } + it 'checks email subject and body for corrections without Silence Vaut Accord' do + expect(subject.subject).to eq("Vous devez corriger votre dossier nº #{dossier.id} « #{dossier.procedure.libelle} »") + expect(subject.body).to include("apporter des corrections") + expect(subject.body).not_to include("Silence") + end end context 'sva with reason is incorrect' do let(:sva_svr_decision_on) { Date.tomorrow } let(:procedure) { create(:procedure, :sva) } - it { expect(subject.subject).to eq("Vous devez corriger votre dossier nº #{dossier.id} « #{dossier.procedure.libelle} »") } - it { expect(subject.body).to include("apporter des corrections") } - it { expect(subject.body).to include("Silence Vaut Accord") } - it { expect(subject.body).to include("suspendu") } + it 'includes Silence Vaut Accord and mentions suspension for incorrect reason' do + expect(subject.subject).to eq("Vous devez corriger votre dossier nº #{dossier.id} « #{dossier.procedure.libelle} »") + expect(subject.body).to include("apporter des corrections") + expect(subject.body).to include("Silence Vaut Accord") + expect(subject.body).to include("suspendu") + end end context 'sva with reason is incomplete' do @@ -260,9 +294,11 @@ RSpec.describe DossierMailer, type: :mailer do let(:reason) { :incomplete } let(:procedure) { create(:procedure, :sva) } - it { expect(subject.body).to include("compléter") } - it { expect(subject.body).to include("Silence Vaut Accord") } - it { expect(subject.body).to include("réinitialisé") } + it 'mentions the need to complete the dossier and includes Silence Vaut Accord with reset message' do + expect(subject.body).to include("compléter") + expect(subject.body).to include("Silence Vaut Accord") + expect(subject.body).to include("réinitialisé") + end end context 'svr with reason is incomplete' do @@ -270,9 +306,11 @@ RSpec.describe DossierMailer, type: :mailer do let(:reason) { :incomplete } let(:procedure) { create(:procedure, :svr) } - it { expect(subject.body).to include("compléter") } - it { expect(subject.body).to include("Silence Vaut Rejet") } - it { expect(subject.body).to include("réinitialisé") } + it 'mentions the need to complete the dossier and includes Silence Vaut Rejet with reset message' do + expect(subject.body).to include("compléter") + expect(subject.body).to include("Silence Vaut Rejet") + expect(subject.body).to include("réinitialisé") + end end end @@ -285,20 +323,26 @@ RSpec.describe DossierMailer, type: :mailer do subject { described_class.with(dossier_transfer: dossier_transfer).notify_transfer } context 'when it is a transfer of one dossier' do - it { expect(subject.subject).to include("Vous avez une demande de transfert en attente.") } - it { expect(subject.body).to include("#{user.email} vous adresse une demande de transfert pour le dossier n° #{dossier.id} sur la démarche") } - it { expect(subject.body).to include(procedure.libelle.to_s) } + it 'includes relevant details about the single dossier transfer request' do + expect(subject.subject).to include("Vous avez une demande de transfert en attente.") + expect(subject.body).to include("#{user.email} vous adresse une demande de transfert pour le dossier n° #{dossier.id} sur la démarche") + expect(subject.body).to include(procedure.libelle.to_s) + end end context 'when recipient has preferred domain' do let(:dossier_transfer) { create(:dossier_transfer, email: create(:user, preferred_domain: :demarches_gouv_fr).email) } - it { expect(subject.body).to include(dossiers_url(statut: "dossiers-transferes", host: ENV.fetch("APP_HOST"))) } + 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"))) + end end context 'when it is a transfer of multiple dossiers' do let!(:dossier2) { create(:dossier, user: user, transfer: dossier_transfer, procedure: procedure) } - it { expect(subject.subject).to include("Vous avez une demande de transfert en attente.") } - it { expect(subject.body).to include("#{user.email} vous adresse une demande de transfert pour 2 dossiers.") } + it 'includes a summary of multiple dossiers transfer request' do + expect(subject.subject).to include("Vous avez une demande de transfert en attente.") + expect(subject.body).to include("#{user.email} vous adresse une demande de transfert pour 2 dossiers.") + end end context 'when it is a transfer of one dossier from super admin' do @@ -306,8 +350,10 @@ RSpec.describe DossierMailer, type: :mailer do dossier_transfer.update!(from_support: true) end - it { expect(subject.subject).to include("Vous avez une demande de transfert en attente.") } - it { expect(subject.body).to include("Le support technique vous adresse une demande de transfert") } + it 'includes details indicating the transfer request is from support' do + expect(subject.subject).to include("Vous avez une demande de transfert en attente.") + expect(subject.body).to include("Le support technique vous adresse une demande de transfert") + end end context 'when dossiers have been dissociated from transfer' do diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb index 0af291a71..831df8985 100644 --- a/spec/mailers/notification_mailer_spec.rb +++ b/spec/mailers/notification_mailer_spec.rb @@ -8,10 +8,12 @@ RSpec.describe NotificationMailer, type: :mailer do subject { described_class.send_notification_for_tiers(dossier_for_tiers) } - it { expect(subject.subject).to include("Votre dossier rempli par le mandataire #{dossier_for_tiers.mandataire_first_name} #{dossier_for_tiers.mandataire_last_name} a été mis à jour") } - it { expect(subject.to).to eq([dossier_for_tiers.individual.email]) } - it { expect(subject.body).to include("a été déposé le") } - it { expect(subject.body).to include("Pour en savoir plus, veuillez vous rapprocher de\r\n#{dossier_for_tiers.user.email}.") } + it 'verifies email subject, recipient, and body content for updated dossier by mandataire' do + expect(subject.subject).to include("Votre dossier rempli par le mandataire #{dossier_for_tiers.mandataire_first_name} #{dossier_for_tiers.mandataire_last_name} a été mis à jour") + expect(subject.to).to eq([dossier_for_tiers.individual.email]) + expect(subject.body).to include("a été déposé le") + expect(subject.body).to include("Pour en savoir plus, veuillez vous rapprocher de\r\n#{dossier_for_tiers.user.email}.") + end end describe 'send_notification_for_tiers for repasser_en_instruction' do @@ -19,10 +21,12 @@ RSpec.describe NotificationMailer, type: :mailer do subject { described_class.send_notification_for_tiers(dossier_for_tiers, repasser_en_instruction: true) } - it { expect(subject.subject).to include("Votre dossier rempli par le mandataire #{dossier_for_tiers.mandataire_first_name} #{dossier_for_tiers.mandataire_last_name} a été mis à jour") } - it { expect(subject.to).to eq([dossier_for_tiers.individual.email]) } - it { expect(subject.body).to include("va être réexaminé, la précédente décision sur ce dossier est caduque.") } - it { expect(subject.body).to include("Pour en savoir plus, veuillez vous rapprocher de\r\n#{dossier_for_tiers.user.email}.") } + it 'verifies email subject, recipient, and body content for dossier re-examination notification' do + expect(subject.subject).to include("Votre dossier rempli par le mandataire #{dossier_for_tiers.mandataire_first_name} #{dossier_for_tiers.mandataire_last_name} a été mis à jour") + expect(subject.to).to eq([dossier_for_tiers.individual.email]) + expect(subject.body).to include("va être réexaminé, la précédente décision sur ce dossier est caduque.") + expect(subject.body).to include("Pour en savoir plus, veuillez vous rapprocher de\r\n#{dossier_for_tiers.user.email}.") + end end describe 'send_en_construction_notification' do @@ -66,13 +70,13 @@ RSpec.describe NotificationMailer, type: :mailer do subject(:mail) { described_class.send_en_instruction_notification(dossier) } - it 'renders the template' do + it 'renders the template with subject and body' do expect(mail.subject).to eq('Email subject') expect(mail.body).to include('Your dossier was processed') expect(mail.body).to have_link('messagerie') end - it 'renders the actions' do + it 'renders the actions with links to dossier and messagerie' do 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 @@ -80,19 +84,16 @@ RSpec.describe NotificationMailer, type: :mailer do context 'when the template body contains tags' do let(:email_template) { create(:received_mail, subject: 'Email subject', body: 'Hello --nom--, your dossier --lien dossier-- was processed.', procedure:) } - it 'replaces value tags with the proper value' do - expect(mail.body).to have_content(dossier.individual.nom) - end - - it 'replaces link tags with a clickable link' do - expect(mail.body).to have_link(dossier_url(dossier, host: ENV.fetch("APP_HOST_LEGACY"))) + it 'replaces value tags with the proper value and renders links correctly' do + expect(mail.body).to include(dossier.individual.nom) + expect(mail.body).to have_link(href: 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"))) + 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(header_value("From", mail)).to include("@demarches.gouv.fr") end end @@ -101,11 +102,8 @@ RSpec.describe NotificationMailer, type: :mailer do context 'when the template body contains HTML' do let(:email_template) { create(:received_mail, body: 'Your dossier was processed. ', procedure:) } - it 'allows basic formatting tags' do + it 'allows basic formatting tags but sanitizes sensitive content' do expect(mail.body).to include('dossier') - end - - it 'sanitizes sensitive content' do expect(mail.body).not_to include('iframe') end end @@ -126,15 +124,17 @@ RSpec.describe NotificationMailer, type: :mailer do subject(:mail) { described_class.send_accepte_notification(dossier) } - context "subject is too long" do + context "when the subject is too long" do let(:subject) { 'Un long libellé --libellé démarche--' } it { expect(mail.subject.length).to be <= 100 } end - context "subject should fallback to default" do + context "when the subject should fallback to default" do let(:subject) { "" } - it { expect(mail.subject).to match(/^Votre dossier .+ a été accepté \(My super long title/) } - it { expect(mail.subject.length).to be <= 100 } + it 'provides a default subject within the length limit including procedure title beginning' do + expect(mail.subject).to match(/^Votre dossier .+ a été accepté \(My super long title/) + expect(mail.subject.length).to be <= 100 + end end end @@ -149,9 +149,11 @@ RSpec.describe NotificationMailer, type: :mailer do subject(:mail) { described_class.send_en_instruction_notification(dossier) } - context "subject has a special character should not be escaped" do + context "when the subject has a special character that should not be escaped" do let(:subject) { '--libellé démarche--' } - it { expect(mail.subject).to eq("Mon titre avec l'apostrophe") } + it 'includes the apostrophe without escaping it' do + expect(mail.subject).to eq("Mon titre avec l'apostrophe") + end end end end diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb index 0ae0bc594..47ad40331 100644 --- a/spec/mailers/user_mailer_spec.rb +++ b/spec/mailers/user_mailer_spec.rb @@ -4,9 +4,11 @@ RSpec.describe UserMailer, type: :mailer do describe '.new_account_warning' do subject { described_class.new_account_warning(user) } - it { expect(subject.to).to eq([user.email]) } - it { expect(subject.body).to include(user.email) } - it { expect(subject.body).to have_link('J’ai oublié mon mot de passe') } + it 'sends email to the correct user with expected body content and link' do + expect(subject.to).to eq([user.email]) + expect(subject.body).to include(user.email) + expect(subject.body).to have_link('J’ai oublié mon mot de passe') + end context 'when a procedure is provided' do let(:procedure) { build(:procedure) } @@ -47,8 +49,10 @@ RSpec.describe UserMailer, type: :mailer do subject { described_class.ask_for_merge(user, requested_email) } - it { expect(subject.to).to eq([requested_email]) } - it { expect(subject.body).to include(requested_email) } + it 'correctly addresses the email and includes the requested email in the body' do + expect(subject.to).to eq([requested_email]) + expect(subject.body).to include(requested_email) + end context 'without SafeMailer configured' do it { expect(subject[BalancerDeliveryMethod::FORCE_DELIVERY_METHOD_HEADER]&.value).to eq(nil) } @@ -68,13 +72,15 @@ RSpec.describe UserMailer, type: :mailer do end describe '.france_connect_merge_confirmation' do - let(:email) { 'new.exemple.fr' } + let(:email) { 'new@exemple.fr' } let(:code) { '123456' } subject { described_class.france_connect_merge_confirmation(email, code, 15.minutes.from_now) } - it { expect(subject.to).to eq([email]) } - it { expect(subject.body).to include(france_connect_particulier_mail_merge_with_existing_account_url(email_merge_token: code))) } + it 'sends to correct email with merge link' do + expect(subject.to).to eq([email]) + expect(subject.body).to include(france_connect_particulier_mail_merge_with_existing_account_url(email_merge_token: code)) + end context 'without SafeMailer configured' do it { expect(subject[BalancerDeliveryMethod::FORCE_DELIVERY_METHOD_HEADER]&.value).to eq(nil) } @@ -100,16 +106,20 @@ RSpec.describe UserMailer, type: :mailer do context 'instructeur' do let(:role) { create(:instructeur) } - it { expect(subject.to).to eq([role.user.email]) } - it { expect(subject.body).to have_link('Consulter mes archives', href: instructeur_archives_url(procedure, host: ENV.fetch("APP_HOST_LEGACY"))) } - it { expect(subject.body).to have_link("#{procedure.id} − #{procedure.libelle}", href: instructeur_procedure_url(procedure, host: ENV.fetch("APP_HOST_LEGACY"))) } + it 'sends email with correct links to instructeur' do + expect(subject.to).to eq([role.user.email]) + expect(subject.body).to have_link('Consulter mes archives', href: instructeur_archives_url(procedure, host: ENV.fetch("APP_HOST_LEGACY"))) + expect(subject.body).to have_link("#{procedure.id} − #{procedure.libelle}", href: instructeur_procedure_url(procedure, host: ENV.fetch("APP_HOST_LEGACY"))) + end end - context 'instructeur' do + context 'administrateur' do let(:role) { create(:administrateur) } - it { expect(subject.to).to eq([role.user.email]) } - it { expect(subject.body).to have_link('Consulter mes archives', href: admin_procedure_archives_url(procedure, host: ENV.fetch("APP_HOST_LEGACY"))) } - it { expect(subject.body).to have_link("#{procedure.id} − #{procedure.libelle}", href: admin_procedure_url(procedure, host: ENV.fetch("APP_HOST_LEGACY"))) } + it 'sends email with correct links to administrateur' do + expect(subject.to).to eq([role.user.email]) + expect(subject.body).to have_link('Consulter mes archives', href: admin_procedure_archives_url(procedure, host: ENV.fetch("APP_HOST_LEGACY"))) + expect(subject.body).to have_link("#{procedure.id} − #{procedure.libelle}", href: admin_procedure_url(procedure, host: ENV.fetch("APP_HOST_LEGACY"))) + end end context 'when perform_later is called' do @@ -125,8 +135,10 @@ RSpec.describe UserMailer, type: :mailer do describe '.notify_inactive_close_to_deletion' do subject { described_class.notify_inactive_close_to_deletion(user) } - it { expect(subject.to).to eq([user.email]) } - it { expect(subject.body).to include("Cela fait plus de deux ans que vous ne vous êtes pas connecté à #{APPLICATION_NAME}.") } + it 'alerts user of inactivity with correct recipient and message' do + expect(subject.to).to eq([user.email]) + expect(subject.body).to include("Cela fait plus de deux ans que vous ne vous êtes pas connecté à #{APPLICATION_NAME}.") + end context 'when perform_later is called' do let(:custom_queue) { 'low_priority' } @@ -142,9 +154,11 @@ RSpec.describe UserMailer, type: :mailer do let(:content) { "Bonjour,\r\nsaut de ligne" } subject { described_class.notify_after_closing(user, content, procedure) } - it { expect(subject.to).to eq([user.email]) } - it { expect(subject.body).to include("Clôture d'une démarche sur Démarches simplifiées") } - it { expect(subject.body).to include("Bonjour,\r\n
saut de ligne") } + it 'notifies user about procedure closing with detailed message' do + expect(subject.to).to eq([user.email]) + expect(subject.body).to include("Clôture d'une démarche sur Démarches simplifiées") + expect(subject.body).to include("Bonjour,\r\n
saut de ligne") + end context 'when perform_later is called' do let(:custom_queue) { 'low_priority' } diff --git a/spec/views/instructeur_mailer/send_notifications.html.haml_spec.rb b/spec/views/instructeur_mailer/send_notifications.html.haml_spec.rb index 37a8e59f5..47aaccdc3 100644 --- a/spec/views/instructeur_mailer/send_notifications.html.haml_spec.rb +++ b/spec/views/instructeur_mailer/send_notifications.html.haml_spec.rb @@ -4,6 +4,8 @@ describe 'instructeur_mailer/send_notifications', type: :view do before do assign(:data, data) + allow(Current).to receive(:application_name).and_return(APPLICATION_NAME) + render end From 16766d73950374136778056865a8570029ba00e0 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Wed, 27 Mar 2024 11:16:29 +0100 Subject: [PATCH 09/14] fix(brakerman): update brakeman with Current false positive --- config/brakeman.ignore | 99 +++++++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 39 deletions(-) diff --git a/config/brakeman.ignore b/config/brakeman.ignore index 12bece0c1..404123563 100644 --- a/config/brakeman.ignore +++ b/config/brakeman.ignore @@ -15,7 +15,7 @@ "type": "controller", "class": "Users::DossiersController", "method": "merci", - "line": 291, + "line": 302, "file": "app/controllers/users/dossiers_controller.rb", "rendered": { "name": "users/dossiers/merci", @@ -44,40 +44,6 @@ ], "note": "" }, - { - "warning_type": "Cross-Site Scripting", - "warning_code": 2, - "fingerprint": "42099f4550a8377f455e830e8ab645cecd5806248481c5c646b4e17548c3cb07", - "check_name": "CrossSiteScripting", - "message": "Unescaped model attribute", - "file": "app/views/france_connect/particulier/merge.html.haml", - "line": 6, - "link": "https://brakemanscanner.org/docs/warning_types/cross_site_scripting", - "code": "t(\".subtitle\", :email => sanitize(FranceConnectInformation.find_by(:merge_token => merge_token_params).email_france_connect), :application_name => (APPLICATION_NAME))", - "render_path": [ - { - "type": "controller", - "class": "FranceConnect::ParticulierController", - "method": "merge", - "line": 47, - "file": "app/controllers/france_connect/particulier_controller.rb", - "rendered": { - "name": "france_connect/particulier/merge", - "file": "app/views/france_connect/particulier/merge.html.haml" - } - } - ], - "location": { - "type": "template", - "template": "france_connect/particulier/merge" - }, - "user_input": "FranceConnectInformation.find_by(:merge_token => merge_token_params).email_france_connect", - "confidence": "Weak", - "cwe_id": [ - 79 - ], - "note": "explicitely sanitized even if we are using html_safe" - }, { "warning_type": "SQL Injection", "warning_code": 0, @@ -85,7 +51,7 @@ "check_name": "SQL", "message": "Possible SQL injection", "file": "app/graphql/connections/cursor_connection.rb", - "line": 66, + "line": 150, "link": "https://brakemanscanner.org/docs/warning_types/sql_injection/", "code": "items.order(order_column => ((:desc or :asc)), :id => ((:desc or :asc))).limit(limit).where(\"(#{order_table}.#{order_column}, #{order_table}.id) < (?, ?)\", timestamp, id)", "render_path": null, @@ -108,7 +74,7 @@ "check_name": "SQL", "message": "Possible SQL injection", "file": "app/graphql/connections/cursor_connection.rb", - "line": 69, + "line": 153, "link": "https://brakemanscanner.org/docs/warning_types/sql_injection/", "code": "items.order(order_column => ((:desc or :asc)), :id => ((:desc or :asc))).limit(limit).where(\"(#{order_table}.#{order_column}, #{order_table}.id) > (?, ?)\", timestamp, id)", "render_path": null, @@ -146,8 +112,63 @@ 89 ], "note": "The table and column are escaped, which should make this safe" + }, + { + "warning_type": "Cross-Site Scripting", + "warning_code": 2, + "fingerprint": "c97049798ff05438dcca6f3ee1a714f2336041837411ab001a7e3caf1bfb75c8", + "check_name": "CrossSiteScripting", + "message": "Unescaped model attribute", + "file": "app/views/layouts/mailers/_signature.html.haml", + "line": 9, + "link": "https://brakemanscanner.org/docs/warning_types/cross_site_scripting", + "code": "Current.application_name.gsub(\".\", \"⁠.\")", + "render_path": [ + { + "type": "template", + "name": "administrateur_mailer/api_token_expiration", + "line": 19, + "file": "app/views/administrateur_mailer/api_token_expiration.haml", + "rendered": { + "name": "layouts/mailers/_signature", + "file": "app/views/layouts/mailers/_signature.html.haml" + } + } + ], + "location": { + "type": "template", + "template": "layouts/mailers/_signature" + }, + "user_input": null, + "confidence": "Medium", + "cwe_id": [ + 79 + ], + "note": "Current is not a model" + }, + { + "warning_type": "Cross-Site Scripting", + "warning_code": 2, + "fingerprint": "f74cfb12b3183f456594e809f222bb2723cc232aa5b8f5f7d9bd6d493c1521fb", + "check_name": "CrossSiteScripting", + "message": "Unescaped model attribute", + "file": "app/views/notification_mailer/send_notification_for_tiers.html.haml", + "line": 29, + "link": "https://brakemanscanner.org/docs/warning_types/cross_site_scripting", + "code": "Current.application_name.gsub(\".\", \"⁠.\")", + "render_path": null, + "location": { + "type": "template", + "template": "notification_mailer/send_notification_for_tiers" + }, + "user_input": null, + "confidence": "Medium", + "cwe_id": [ + 79 + ], + "note": "Current is not a model" } ], - "updated": "2023-08-28 12:16:04 +0200", - "brakeman_version": "5.4.1" + "updated": "2024-03-27 17:15:54 +0100", + "brakeman_version": "6.1.2" } From df198a8946151c1bbe3a92ae6893aee52aaa78ba Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Wed, 27 Mar 2024 14:41:38 +0100 Subject: [PATCH 10/14] style(mailer): big button in dsfr style --- app/helpers/mailer_helper.rb | 2 +- app/views/shared/_mailer_round_button.html.haml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb index e653e703c..3664cb3ce 100644 --- a/app/helpers/mailer_helper.rb +++ b/app/helpers/mailer_helper.rb @@ -19,7 +19,7 @@ module MailerHelper end def blue - '#0069CC' + '#000091' end def white diff --git a/app/views/shared/_mailer_round_button.html.haml b/app/views/shared/_mailer_round_button.html.haml index 77e0a452b..a16ccb35c 100644 --- a/app/views/shared/_mailer_round_button.html.haml +++ b/app/views/shared/_mailer_round_button.html.haml @@ -4,6 +4,6 @@ %td{ align: "center" } %table{ border:"0", cellspacing:"0", cellpadding:"0" } %tr - %td{ align:"center", style:"border-radius: 5px;", color: theme[:color], bgcolor: theme[:bg_color] } - %a{ href: url, target:"_blank", rel: "noopener", style:"font-size: 16px; font-family: Helvetica, Arial, sans-serif; color: #{theme[:color]}; text-decoration: none; text-decoration: none; border-radius: 5px; padding: 12px 25px; border: 1px solid #{theme[:border_color]}; display: inline-block; min-width: 250px" } + %td{ align:"center", color: theme[:color], bgcolor: theme[:bg_color] } + %a{ href: url, target:"_blank", rel: "noopener", style:"font-size: 18px; font-family: Helvetica, Arial, sans-serif; color: #{theme[:color]}; text-decoration: none; text-decoration: none; padding: 8px 24px; border: 1px solid #{theme[:border_color]}; display: inline-block; min-width: 200px; min-height: 32px; line-height: 32px;" } = text From 172aeec3dc908cd12d1562bc6e07dbf39ad7486f Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Wed, 27 Mar 2024 16:44:47 +0100 Subject: [PATCH 11/14] chore(mail): replace textual logo with simple logo + application name as text --- .../instructeur_mailer/logo-beta-gouv-fr.png | Bin 1979 -> 0 bytes .../images/mailer/instructeur_mailer/logo.png | Bin 6773 -> 0 bytes .../mailer/republique-francaise-logo.png | Bin 0 -> 5346 bytes app/views/layouts/mailers/layout.html.erb | 34 ++++++++---------- config/env.example.optional | 5 +-- config/environments/test.rb | 1 + config/initializers/images.rb | 3 +- 7 files changed, 18 insertions(+), 25 deletions(-) delete mode 100644 app/assets/images/mailer/instructeur_mailer/logo-beta-gouv-fr.png delete mode 100644 app/assets/images/mailer/instructeur_mailer/logo.png create mode 100644 app/assets/images/mailer/republique-francaise-logo.png diff --git a/app/assets/images/mailer/instructeur_mailer/logo-beta-gouv-fr.png b/app/assets/images/mailer/instructeur_mailer/logo-beta-gouv-fr.png deleted file mode 100644 index 7cb725c37de695c23ef658c6669b9decd5fd7f9c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1979 zcmV;s2SoUZP)^S zpxN1;nV$KZBWqc6U3c-K7hPI#!;6b<_+ZfsU&z&Jiy9}(gz>89tBos9De&lw0X5Hzf)@0Q%~ziF?ktQ88;lA{0a z1ur^Pz4JV8X@F&$ZMK;&1I$D%Yohl@ME?VGxg8cvnwtS81IrGv{_jn-kO7l(YpaNR z+F8iYi}L($(Fy;N`1X?UjlJ8pZ9A8Jm-FY8HEm_hQ__Et-bMO%((f#~HP^sj&Mi98 z^Yrb(!ej1`?;X$cK)ghrGiC3O;yr)G0mWr*T6Fvp)}WW%=)|rZrFBSb*b^i)(l?ad^Ij|KaqIXm9P=cfX+Ww&T|(GBhHjM z6rJFlf)_lD`vw3NF_!0-kv$P$s0(Y371tBb+F@EL0c6A0BJ>Y5XMiZ|0a<@lY;hxK z>^V}&dz_5@8OzkeAoJVxSys5J%M1Jy9lg$prOaH9QWUW0t+26!K2Q*uvdGhmQ= z?`sKLkEuEMn0gP6quv9x0F&Mkvk4f_CIbc+$KEA4(jwD?DFK6h`x3wpF--y=FaZXs zC&~K*LWbcY0`@*gQ6~p5Xeg%9cb~+&TrM{cbVhg5P$yOp73PK!7GZG3Xjy$c_Tr z-{CM(sD|O>0tS~V?}s&Ww`#-MFl^fIt8|>T<|?jbBGCXkJeC;LZN_RZ^8`#VD3$vqh`VDNmgP?$xgozeiNS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eHN4HncFj-RU0{$~em8F4M-GK?HN}FsvamZ&w@S5iAvdBMCyBIu zAIFoQ;`&eg!)~{}SShKI#husB9j%f~MPU-O7QS6u_}<_t5&p}C%!V(!Oie#t+)Zrz ejBIFZvJE&2+O$2XuY33RNl8&wO{P@J)bBru{zHxc literal 0 HcmV?d00001 diff --git a/app/views/layouts/mailers/layout.html.erb b/app/views/layouts/mailers/layout.html.erb index 0fb74b8f5..a7067a244 100644 --- a/app/views/layouts/mailers/layout.html.erb +++ b/app/views/layouts/mailers/layout.html.erb @@ -42,23 +42,6 @@ -
- - - - - - -
-
- Logo <%= " src="<%= image_url("#{MAILER_LOGO_SRC}") %>" style="max-width=600px; padding=30px 0; display=inline !important; vertical-align=bottom; border=0; height=auto; outline=none; text-decoration=none; -ms-interpolation-mode=bicubic;" /> -
-
-
-
@@ -108,7 +91,20 @@
- <%= yield(:procedure_logo) %> + <%- if content_for?(:procedure_logo) %> + <%= yield :procedure_logo %> + <%- else -%> + + + + <%- end -%> diff --git a/config/env.example.optional b/config/env.example.optional index 293f03ea7..df8621781 100644 --- a/config/env.example.optional +++ b/config/env.example.optional @@ -82,10 +82,7 @@ DS_ENV="staging" # HEADER_LOGO_HEIGHT="56" # Instance customization: Emails header logo ---> to be put in "app/assets/images" -# MAILER_LOGO_SRC="mailer/instructeur_mailer/logo.png" - -# Instance customization: Emails footer logo ---> to be put in "app/assets/images" -# MAILER_FOOTER_LOGO_SRC="mailer/instructeur_mailer/logo-beta-gouv-fr.png" +# MAILER_LOGO_SRC="mailer/republique-francaise-logo.png" # Instance customization: Procedure default logo ---> to be put in "app/assets/images" # PROCEDURE_DEFAULT_LOGO_SRC="republique-francaise-logo.svg" diff --git a/config/environments/test.rb b/config/environments/test.rb index 3f79b3b0f..7880fc7b5 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -64,6 +64,7 @@ Rails.application.configure do # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true config.action_mailer.default_url_options = { host: ENV.fetch("APP_HOST") } + config.action_mailer.asset_host = "http://" + ENV.fetch("APP_HOST") Rails.application.routes.default_url_options = { host: ENV.fetch("APP_HOST"), protocol: :http diff --git a/config/initializers/images.rb b/config/initializers/images.rb index 9bf0804dc..9a2f78534 100644 --- a/config/initializers/images.rb +++ b/config/initializers/images.rb @@ -13,8 +13,7 @@ HEADER_LOGO_WIDTH = ENV.fetch("HEADER_LOGO_WIDTH", "65") HEADER_LOGO_HEIGHT = ENV.fetch("HEADER_LOGO_HEIGHT", "56") # Mailer logos -MAILER_LOGO_SRC = ENV.fetch("MAILER_LOGO_SRC", "mailer/instructeur_mailer/logo.png") -MAILER_FOOTER_LOGO_SRC = ENV.fetch("MAILER_FOOTER_LOGO_SRC", "mailer/instructeur_mailer/logo-beta-gouv-fr.png") +MAILER_LOGO_SRC = ENV.fetch("MAILER_LOGO_SRC", "mailer/republique-francaise-logo.png") # Default logo of a procedure PROCEDURE_DEFAULT_LOGO_SRC = ENV.fetch("PROCEDURE_DEFAULT_LOGO_SRC", "republique-francaise-logo.svg") From 36fc53538694fde6325ad96daf2389aec7f83e42 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Thu, 28 Mar 2024 12:30:31 +0100 Subject: [PATCH 12/14] refactor(mailer): for devise mailer set locale in dedicated action --- .../mailer_defaults_configurable_concern.rb | 2 -- app/mailers/devise_user_mailer.rb | 5 ++++- spec/mailers/devise_user_mailer_spec.rb | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/mailers/concerns/mailer_defaults_configurable_concern.rb b/app/mailers/concerns/mailer_defaults_configurable_concern.rb index 8ab29d33f..0bf67ba86 100644 --- a/app/mailers/concerns/mailer_defaults_configurable_concern.rb +++ b/app/mailers/concerns/mailer_defaults_configurable_concern.rb @@ -32,8 +32,6 @@ module MailerDefaultsConfigurableConcern def configure_defaults_for_user(user) return if !user.is_a?(User) # not for super-admins - I18n.locale = user.locale - if user.preferred_domain_demarches_gouv_fr? set_currents_for_demarches_gouv_fr else diff --git a/app/mailers/devise_user_mailer.rb b/app/mailers/devise_user_mailer.rb index fcebeb0e1..d9acb25c3 100644 --- a/app/mailers/devise_user_mailer.rb +++ b/app/mailers/devise_user_mailer.rb @@ -33,7 +33,10 @@ class DeviseUserMailer < Devise::Mailer opts[:reply_to] = Current.no_reply_email @procedure = opts[:procedure_after_confirmation] || nil @prefill_token = opts[:prefill_token] - super + + I18n.with_locale(record.locale) do + super + end end def self.critical_email?(action_name) diff --git a/spec/mailers/devise_user_mailer_spec.rb b/spec/mailers/devise_user_mailer_spec.rb index c020e9e4f..1b6160c6b 100644 --- a/spec/mailers/devise_user_mailer_spec.rb +++ b/spec/mailers/devise_user_mailer_spec.rb @@ -19,6 +19,24 @@ RSpec.describe DeviseUserMailer, type: :mailer do expect { subject.deliver_later }.to have_enqueued_job.on_queue(Rails.application.config.action_mailer.deliver_later_queue_name) end end + + describe "i18n" do + context "when locale is fr" do + let(:user) { create(:user, locale: :fr) } + + it "uses fr locale" do + expect(subject.body).to include("Activez votre compte") + end + end + + context "when locale is en" do + let(:user) { create(:user, locale: :en) } + + it "uses en locale" do + expect(subject.body).to include("Activate account") + end + end + end end describe 'headers for user' do From 32bcf5b75dcb0c027ea9151cf621e2dcf234b466 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Thu, 28 Mar 2024 14:34:47 +0100 Subject: [PATCH 13/14] fix(mailtrap): update to 2024 config --- config/initializers/mailtrap.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/initializers/mailtrap.rb b/config/initializers/mailtrap.rb index 6d1faa04b..481bd2684 100644 --- a/config/initializers/mailtrap.rb +++ b/config/initializers/mailtrap.rb @@ -8,10 +8,10 @@ if ENV.fetch('MAILTRAP_ENABLED') == 'enabled' ActionMailer::Base.mailtrap_settings = { user_name: Rails.application.secrets.mailtrap[:username], password: Rails.application.secrets.mailtrap[:password], - address: 'smtp.mailtrap.io', - domain: 'smtp.mailtrap.io', + address: 'sandbox.smtp.mailtrap.io', + domain: 'sandbox.smtp.mailtrap.io', port: '2525', - authentication: :cram_md5 + authentication: :login } end end From 95e80d6ce304d3701b78ce9aa2531a80a6f38886 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Tue, 2 Apr 2024 15:44:42 +0200 Subject: [PATCH 14/14] fix(layout): header text alignemnt --- app/views/layouts/_header.haml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/layouts/_header.haml b/app/views/layouts/_header.haml index 148cbb83c..c5711555e 100644 --- a/app/views/layouts/_header.haml +++ b/app/views/layouts/_header.haml @@ -37,8 +37,7 @@ = render partial: 'layouts/account_dropdown', locals: { nav_bar_profile: nav_bar_profile, dossier: dossier } - elsif (request.path != new_user_session_path && request.path !=agent_connect_path) - if request.path == new_user_registration_path - %li - .fr-hidden-sm.fr-unhidden-lg.fr-link--sm= t('views.shared.account.already_user_question') + %li.fr-hidden-sm.fr-unhidden-lg.fr-link--sm.fr-mb-2w.fr-mr-1v= t('views.shared.account.already_user_question') %li= link_to 'Agent', agent_connect_path, class: "fr-btn fr-btn--tertiary fr-icon-government-fill fr-btn--icon-left" %li= link_to t('views.shared.account.signin'), new_user_session_path, class: "fr-btn fr-btn--tertiary fr-icon-account-circle-fill fr-btn--icon-left"
+

+ Logo <%= " src="<%= image_url(MAILER_LOGO_SRC) %>" style="max-height:100px; padding:15px 30px 15px 30px; vertical-aligne:middle; display:inline !important; border:0; height:auto; outline:none; text-decoration:none; -ms-interpolation-mode:bicubic;" /> + + <%= Current.application_name %> + +

+
@@ -168,7 +164,7 @@
- Logo <%= " src="<%= image_url("#{MAILER_FOOTER_LOGO_SRC}") %>" style="max-width=125px; padding=30px 0; display=inline !important; vertical-align=bottom; border=0; height=auto; outline=none; text-decoration=none; -ms-interpolation-mode=bicubic;" /> + <%= "#{Current.application_name}" %> est un service fourni par <%= t("links.provider.provided_by") %>