From d80bf601e13619fd70930b658287cd7e7ce66b73 Mon Sep 17 00:00:00 2001
From: maatinito <15379878+maatinito@users.noreply.github.com>
Date: Thu, 20 Dec 2018 09:50:10 +0100
Subject: [PATCH 1/5] [#325] Add support for a footer in layout.html.erb
---
app/views/layouts/mailers/layout.html.erb | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/app/views/layouts/mailers/layout.html.erb b/app/views/layouts/mailers/layout.html.erb
index 7f387ece8..61f42cf22 100644
--- a/app/views/layouts/mailers/layout.html.erb
+++ b/app/views/layouts/mailers/layout.html.erb
@@ -116,6 +116,18 @@
+ <% if content_for?(:footer) %>
+
+
+
+ —
+
+
+ <%= yield(:footer) %>
+
+ |
+
+ <% end %>
From a1a11adb83171c1715bf33682efd79d7b9db0597 Mon Sep 17 00:00:00 2001
From: maatinito <15379878+maatinito@users.noreply.github.com>
Date: Thu, 20 Dec 2018 09:49:14 +0100
Subject: [PATCH 2/5] [#325] Make the notification layout inherit from the
general layout
---
app/views/layouts/mailers/notification.html.haml | 15 ++++++---------
spec/mailers/notification_mailer_spec.rb | 4 ++--
2 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/app/views/layouts/mailers/notification.html.haml b/app/views/layouts/mailers/notification.html.haml
index 65200ed40..b2fb59b7c 100644
--- a/app/views/layouts/mailers/notification.html.haml
+++ b/app/views/layouts/mailers/notification.html.haml
@@ -1,10 +1,7 @@
-= yield
+- content_for :footer do
+ %strong
+ Merci de ne pas répondre à cet email. Pour vous adresser à votre administration, passez directement par votre
+ = succeed '.' do
+ = link_to 'messagerie', messagerie_dossier_url(@dossier), target: '_blank'
-%footer
- %p
- —
- %br
- %strong
- Merci de ne pas répondre à cet email. Pour vous adresser à votre administration, passez directement par votre
- = succeed '.' do
- = link_to 'messagerie', messagerie_dossier_url(@dossier), target: '_blank'
+= render template: 'layouts/mailers/layout'
diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb
index 1be85a653..89a1c9333 100644
--- a/spec/mailers/notification_mailer_spec.rb
+++ b/spec/mailers/notification_mailer_spec.rb
@@ -34,7 +34,7 @@ RSpec.describe NotificationMailer, type: :mailer do
it { expect(mail.subject).to eq(email_template.subject_for_dossier) }
it { expect(mail.body).to include(email_template.body_for_dossier) }
- it { expect(mail.body).to have_selector('footer') }
+ it { expect(mail.body).to have_link('messagerie') }
it_behaves_like "create a commentaire not notified"
end
@@ -50,7 +50,7 @@ RSpec.describe NotificationMailer, type: :mailer do
it do
expect(mail.subject).to eq(email_template.subject)
expect(mail.body).to include(email_template.body)
- expect(mail.body).to have_selector('footer')
+ expect(mail.body).to have_link('messagerie')
end
it_behaves_like "create a commentaire not notified"
From e4883aa1527a7144348be4d8176d4e2d3f72c5ec Mon Sep 17 00:00:00 2001
From: maatinito <15379878+maatinito@users.noreply.github.com>
Date: Thu, 20 Dec 2018 09:49:41 +0100
Subject: [PATCH 3/5] =?UTF-8?q?[Fix=20#325]=20Set=20InviteMailer=E2=80=99s?=
=?UTF-8?q?=20layout?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/mailers/invite_mailer.rb | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/mailers/invite_mailer.rb b/app/mailers/invite_mailer.rb
index 7d0be51e6..826a18100 100644
--- a/app/mailers/invite_mailer.rb
+++ b/app/mailers/invite_mailer.rb
@@ -1,5 +1,7 @@
# Preview all emails at http://localhost:3000/rails/mailers/invite_mailer
class InviteMailer < ApplicationMailer
+ layout 'mailers/layout'
+
def invite_user(invite)
subject = "Participez à l'élaboration d'un dossier"
From 9842142a9a7a8ca9c0cc96304a56c32fc58eb448 Mon Sep 17 00:00:00 2001
From: maatinito <15379878+maatinito@users.noreply.github.com>
Date: Thu, 20 Dec 2018 09:50:20 +0100
Subject: [PATCH 4/5] Add InviteMailerPreview
---
.../mailers/previews/invite_mailer_preview.rb | 33 +++++++++++++++++++
1 file changed, 33 insertions(+)
create mode 100644 spec/mailers/previews/invite_mailer_preview.rb
diff --git a/spec/mailers/previews/invite_mailer_preview.rb b/spec/mailers/previews/invite_mailer_preview.rb
new file mode 100644
index 000000000..f594f2ae8
--- /dev/null
+++ b/spec/mailers/previews/invite_mailer_preview.rb
@@ -0,0 +1,33 @@
+class InviteMailerPreview < ActionMailer::Preview
+ def invite_user
+ InviteMailer.invite_user(invite)
+ end
+
+ def invite_guest
+ InviteMailer.invite_guest(invite)
+ end
+
+ private
+
+ def invite
+ Invite.new(
+ id: 10,
+ dossier: dossier,
+ user: invited_user,
+ email: invited_user.email,
+ email_sender: 'sender@gouv.fr'
+ )
+ end
+
+ def dossier
+ Dossier.new(procedure: procedure)
+ end
+
+ def procedure
+ Procedure.new(libelle: 'Permis de construire en zone inondable')
+ end
+
+ def invited_user
+ User.new(email: 'Invité@gouv.fr')
+ end
+end
From e37372d261d4da095c4470526c877a8be1d34cd4 Mon Sep 17 00:00:00 2001
From: maatinito <15379878+maatinito@users.noreply.github.com>
Date: Thu, 20 Dec 2018 09:40:05 +0100
Subject: [PATCH 5/5] Fix a typo
---
spec/mailers/notification_mailer_spec.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb
index 89a1c9333..1d6702ffb 100644
--- a/spec/mailers/notification_mailer_spec.rb
+++ b/spec/mailers/notification_mailer_spec.rb
@@ -23,7 +23,7 @@ RSpec.describe NotificationMailer, type: :mailer do
# 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,
- # because ActionMailer does some magic to expose public instace methods as class methods.
+ # because ActionMailer does some magic to expose public instance methods as class methods.
# So, we use inheritance instead to make the private method public for testing purposes.
def send_notification(dossier, template)
super