Merge pull request #2419 from betagouv/template_notifications
Add layout for notifications mails
This commit is contained in:
commit
fabfa7d5e6
9 changed files with 26 additions and 44 deletions
|
@ -48,7 +48,13 @@ class NotificationMailer < ApplicationMailer
|
||||||
|
|
||||||
create_commentaire_for_notification(dossier, subject, body)
|
create_commentaire_for_notification(dossier, subject, body)
|
||||||
|
|
||||||
mail(subject: subject, to: email) { |format| format.html { body } }
|
@dossier = dossier
|
||||||
|
|
||||||
|
mail(subject: subject, to: email) do |format|
|
||||||
|
# rubocop:disable Rails/OutputSafety
|
||||||
|
format.html { render(html: body.html_safe, layout: 'mailers/notification') }
|
||||||
|
# rubocop:enable Rails/OutputSafety
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_commentaire_for_notification(dossier, subject, body)
|
def create_commentaire_for_notification(dossier, subject, body)
|
||||||
|
|
9
app/views/layouts/mailers/notification.html.haml
Normal file
9
app/views/layouts/mailers/notification.html.haml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
= yield
|
||||||
|
|
||||||
|
%p ---
|
||||||
|
|
||||||
|
%p.footer
|
||||||
|
%strong
|
||||||
|
Merci de ne pas répondre à cet email. Pour vous adresser à votre administration, passez directement par votre
|
||||||
|
= succeed '.' do
|
||||||
|
= link_to 'messagerie', users_dossier_recapitulatif_url(@dossier), target: '_blank'
|
|
@ -12,9 +12,3 @@
|
||||||
|
|
||||||
%p
|
%p
|
||||||
L'équipe demarches-simplifiees.fr
|
L'équipe demarches-simplifiees.fr
|
||||||
|
|
||||||
%p
|
|
||||||
—
|
|
||||||
|
|
||||||
%p
|
|
||||||
Merci de ne pas répondre à cet email. Postez directement vos questions dans votre dossier sur la plateforme.
|
|
||||||
|
|
|
@ -15,9 +15,3 @@
|
||||||
|
|
||||||
%p
|
%p
|
||||||
L'équipe demarches-simplifiees.fr
|
L'équipe demarches-simplifiees.fr
|
||||||
|
|
||||||
%p
|
|
||||||
—
|
|
||||||
|
|
||||||
%p
|
|
||||||
Merci de ne pas répondre à cet email. Postez directement vos questions dans votre dossier sur la plateforme.
|
|
||||||
|
|
|
@ -12,9 +12,3 @@
|
||||||
|
|
||||||
%p
|
%p
|
||||||
L'équipe demarches-simplifiees.fr
|
L'équipe demarches-simplifiees.fr
|
||||||
|
|
||||||
%p
|
|
||||||
—
|
|
||||||
|
|
||||||
%p
|
|
||||||
Merci de ne pas répondre à cet email. Postez directement vos questions dans votre dossier sur la plateforme.
|
|
||||||
|
|
|
@ -9,9 +9,3 @@
|
||||||
|
|
||||||
%p
|
%p
|
||||||
L'équipe demarches-simplifiees.fr
|
L'équipe demarches-simplifiees.fr
|
||||||
|
|
||||||
%p
|
|
||||||
—
|
|
||||||
|
|
||||||
%p
|
|
||||||
Merci de ne pas répondre à cet email. Postez directement vos questions dans votre dossier sur la plateforme.
|
|
||||||
|
|
|
@ -15,9 +15,3 @@
|
||||||
|
|
||||||
%p
|
%p
|
||||||
L'équipe demarches-simplifiees.fr
|
L'équipe demarches-simplifiees.fr
|
||||||
|
|
||||||
%p
|
|
||||||
—
|
|
||||||
|
|
||||||
%p
|
|
||||||
Merci de ne pas répondre à cet email. Postez directement vos questions dans votre dossier sur la plateforme.
|
|
||||||
|
|
|
@ -15,9 +15,3 @@
|
||||||
|
|
||||||
%p
|
%p
|
||||||
L'équipe demarches-simplifiees.fr
|
L'équipe demarches-simplifiees.fr
|
||||||
|
|
||||||
%p
|
|
||||||
—
|
|
||||||
|
|
||||||
%p
|
|
||||||
Merci de ne pas répondre à cet email. Postez directement vos questions dans votre dossier sur la plateforme.
|
|
||||||
|
|
|
@ -18,11 +18,11 @@ RSpec.describe NotificationMailer, type: :mailer do
|
||||||
describe '.send_notification' do
|
describe '.send_notification' do
|
||||||
let(:email_template) { instance_double('email_template', subject_for_dossier: 'subject', body_for_dossier: 'body') }
|
let(:email_template) { instance_double('email_template', subject_for_dossier: 'subject', body_for_dossier: 'body') }
|
||||||
|
|
||||||
subject do
|
subject(:mail) do
|
||||||
klass = Class.new(described_class) do
|
klass = Class.new(described_class) do
|
||||||
# We’re testing the (private) method `NotificationMailer#send_notification`.
|
# We’re testing the (private) method `NotificationMailer#send_notification`.
|
||||||
#
|
#
|
||||||
# The standard trick to test a private method would be to `send(:send_notification`, but doesn’t work here,
|
# The standard trick to test a private method would be to `send(:send_notification)`, but doesn’t work here,
|
||||||
# because ActionMailer does some magic to expose public instace methods as class methods.
|
# because ActionMailer does some magic to expose public instace methods as class methods.
|
||||||
# So, we use inheritance instead to make the private method public for testing purposes.
|
# So, we use inheritance instead to make the private method public for testing purposes.
|
||||||
def send_notification(dossier, template)
|
def send_notification(dossier, template)
|
||||||
|
@ -32,13 +32,15 @@ RSpec.describe NotificationMailer, type: :mailer do
|
||||||
klass.send_notification(dossier, email_template)
|
klass.send_notification(dossier, email_template)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(subject.subject).to eq(email_template.subject_for_dossier) }
|
it { expect(mail.subject).to eq(email_template.subject_for_dossier) }
|
||||||
it { expect(subject.body).to eq(email_template.body_for_dossier) }
|
it { expect(mail.body).to include(email_template.body_for_dossier) }
|
||||||
|
it { expect(mail.body).to have_selector('.footer') }
|
||||||
|
|
||||||
it_behaves_like "create a commentaire not notified"
|
it_behaves_like "create a commentaire not notified"
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.send_dossier_received' do
|
describe '.send_dossier_received' do
|
||||||
subject { described_class.send_dossier_received(dossier) }
|
subject(:mail) { described_class.send_dossier_received(dossier) }
|
||||||
let(:email_template) { create(:received_mail) }
|
let(:email_template) { create(:received_mail) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -46,8 +48,9 @@ RSpec.describe NotificationMailer, type: :mailer do
|
||||||
end
|
end
|
||||||
|
|
||||||
it do
|
it do
|
||||||
expect(subject.subject).to eq(email_template.subject)
|
expect(mail.subject).to eq(email_template.subject)
|
||||||
expect(subject.body).to eq(email_template.body)
|
expect(mail.body).to include(email_template.body)
|
||||||
|
expect(mail.body).to have_selector('.footer')
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like "create a commentaire not notified"
|
it_behaves_like "create a commentaire not notified"
|
||||||
|
|
Loading…
Reference in a new issue