Merge pull request #3004 from betagouv/fix-new-message-footer
Corrige le lien direct vers la messagerie dans l'email "Vous avez un nouveau message"
This commit is contained in:
commit
dde43141ef
19 changed files with 79 additions and 39 deletions
|
@ -1,3 +1,4 @@
|
|||
# Preview all emails at http://localhost:3000/rails/mailers/administrateur_mailer
|
||||
class AdministrateurMailer < ApplicationMailer
|
||||
layout 'mailers/layout'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# Preview all emails at http://localhost:3000/rails/mailers/administration_mailer
|
||||
class AdministrationMailer < ApplicationMailer
|
||||
layout 'mailers/layout'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# Preview all emails at http://localhost:3000/rails/mailers/avis_mailer
|
||||
class AvisMailer < ApplicationMailer
|
||||
def avis_invitation(avis)
|
||||
@avis = avis
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# Preview all emails at http://localhost:3000/rails/mailers/devise_user_mailer
|
||||
class DeviseUserMailer < Devise::Mailer
|
||||
helper :application # gives access to all helpers defined within `application_helper`.
|
||||
include Devise::Controllers::UrlHelpers # Optional. eg. `confirmation_url`
|
||||
|
|
|
@ -1,6 +1,23 @@
|
|||
# Preview all emails at http://localhost:3000/rails/mailers/dossier_mailer
|
||||
class DossierMailer < ApplicationMailer
|
||||
layout 'mailers/layout'
|
||||
|
||||
def notify_new_draft(dossier)
|
||||
@dossier = dossier
|
||||
subject = "Retrouvez votre brouillon pour la démarche \"#{dossier.procedure.libelle}\""
|
||||
|
||||
mail(to: dossier.user.email, subject: subject)
|
||||
end
|
||||
|
||||
def notify_new_answer(dossier)
|
||||
@dossier = dossier
|
||||
subject = "Nouveau message pour votre dossier nº #{dossier.id}"
|
||||
|
||||
mail(to: dossier.user.email, subject: subject) do |format|
|
||||
format.html { render layout: 'mailers/notification' }
|
||||
end
|
||||
end
|
||||
|
||||
def notify_deletion_to_user(deleted_dossier, to_email)
|
||||
@deleted_dossier = deleted_dossier
|
||||
subject = "Votre dossier n° #{@deleted_dossier.dossier_id} a bien été supprimé"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# Preview all emails at http://localhost:3000/rails/mailers/gestionnaire_mailer
|
||||
class GestionnaireMailer < ApplicationMailer
|
||||
layout 'mailers/layout'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# Preview all emails at http://localhost:3000/rails/mailers/invite_mailer
|
||||
class InviteMailer < ApplicationMailer
|
||||
def invite_user(invite)
|
||||
subject = "Participez à l'élaboration d'un dossier"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# Preview all emails at http://localhost:3000/rails/mailers/new_attestation_mailer
|
||||
class NewAttestationMailer < ApplicationMailer
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
# Preview all emails at http://localhost:3000/rails/mailers/notification_mailer
|
||||
|
||||
# A Notification is attached as a Comment to the relevant discussion,
|
||||
# then sent by email to the user.
|
||||
#
|
||||
# The subject and body of a Notification can be customized by each demarche.
|
||||
#
|
||||
class NotificationMailer < ApplicationMailer
|
||||
def new_answer(dossier)
|
||||
subject = "Nouveau message pour votre dossier nº #{dossier.id}"
|
||||
|
||||
send_mail(dossier, subject)
|
||||
end
|
||||
|
||||
def send_draft_notification(dossier)
|
||||
subject = "Retrouvez votre brouillon pour la démarche \"#{dossier.procedure.libelle}\""
|
||||
|
||||
send_mail(dossier, subject)
|
||||
end
|
||||
|
||||
def send_dossier_received(dossier)
|
||||
send_notification(dossier, dossier.procedure.received_mail_template)
|
||||
end
|
||||
|
@ -33,13 +28,6 @@ class NotificationMailer < ApplicationMailer
|
|||
|
||||
private
|
||||
|
||||
def send_mail(dossier, subject)
|
||||
@dossier = dossier
|
||||
email = dossier.user.email
|
||||
|
||||
mail(subject: subject, to: email)
|
||||
end
|
||||
|
||||
def send_notification(dossier, mail_template)
|
||||
email = dossier.user.email
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# Preview all emails at http://localhost:3000/rails/mailers/user_mailer
|
||||
class UserMailer < ApplicationMailer
|
||||
layout 'mailers/layout'
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class Commentaire < ApplicationRecord
|
|||
end
|
||||
|
||||
def notify_user
|
||||
NotificationMailer.new_answer(dossier).deliver_later
|
||||
DossierMailer.notify_new_answer(dossier).deliver_later
|
||||
end
|
||||
|
||||
def is_virus_free?
|
||||
|
|
|
@ -356,7 +356,7 @@ class Dossier < ApplicationRecord
|
|||
|
||||
def send_draft_notification_email
|
||||
if brouillon?
|
||||
NotificationMailer.send_draft_notification(self).deliver_later
|
||||
DossierMailer.notify_new_draft(self).deliver_later
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -13,9 +13,3 @@
|
|||
|
||||
%p
|
||||
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.
|
|
@ -3,6 +3,27 @@ require "rails_helper"
|
|||
RSpec.describe DossierMailer, type: :mailer do
|
||||
let(:to_email) { 'gestionnaire@exemple.gouv.fr' }
|
||||
|
||||
describe '.notify_new_draft' do
|
||||
let(:dossier) { create(:dossier, procedure: build(:simple_procedure)) }
|
||||
|
||||
subject { described_class.notify_new_draft(dossier) }
|
||||
|
||||
it { expect(subject.subject).to include("brouillon") }
|
||||
it { expect(subject.subject).to include(dossier.id.to_s) }
|
||||
it { expect(subject.body).to include(dossier.procedure.libelle) }
|
||||
it { expect(subject.body).to include(dossier_url(dossier)) }
|
||||
end
|
||||
|
||||
describe '.notify_new_answer' do
|
||||
let(:dossier) { create(:dossier, procedure: build(:simple_procedure)) }
|
||||
|
||||
subject { described_class.notify_new_answer(dossier) }
|
||||
|
||||
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)) }
|
||||
end
|
||||
|
||||
describe '.notify_deletion_to_user' do
|
||||
let(:deleted_dossier) { build(:deleted_dossier) }
|
||||
|
||||
|
|
|
@ -55,12 +55,4 @@ RSpec.describe NotificationMailer, type: :mailer do
|
|||
|
||||
it_behaves_like "create a commentaire not notified"
|
||||
end
|
||||
|
||||
describe ".new_answer" do
|
||||
subject(:subject) { described_class.new_answer(dossier) }
|
||||
|
||||
it { expect(subject.body).to match('Un nouveau message est disponible dans votre espace demarches-simplifiees.fr.') }
|
||||
it { expect(subject.body).to include(messagerie_dossier_url(dossier)) }
|
||||
it { expect(subject.subject).to eq("Nouveau message pour votre dossier nº #{dossier.id}") }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
# Preview all emails at http://localhost:3000/rails/mailers/dossier_mailer
|
||||
class DossierMailerPreview < ActionMailer::Preview
|
||||
def notify_new_draft
|
||||
DossierMailer.notify_new_draft(Dossier.last)
|
||||
end
|
||||
|
||||
def notify_new_answer
|
||||
DossierMailer.notify_new_answer(Dossier.last)
|
||||
end
|
||||
|
||||
def notify_deletion_to_user
|
||||
DossierMailer.notify_deletion_to_user(DeletedDossier.last, "user@ds.fr")
|
||||
end
|
||||
|
|
|
@ -1,9 +1,21 @@
|
|||
class NotificationMailerPreview < ActionMailer::Preview
|
||||
def send_notification
|
||||
def send_dossier_received
|
||||
NotificationMailer.send_dossier_received(Dossier.last)
|
||||
end
|
||||
|
||||
def send_initiated_notification
|
||||
NotificationMailer.send_initiated_notification(Dossier.last)
|
||||
end
|
||||
|
||||
def send_draft_notification
|
||||
NotificationMailer.send_draft_notification(Dossier.last)
|
||||
def send_closed_notification
|
||||
NotificationMailer.send_closed_notification(Dossier.last)
|
||||
end
|
||||
|
||||
def send_refused_notification
|
||||
NotificationMailer.send_refused_notification(Dossier.last)
|
||||
end
|
||||
|
||||
def send_without_continuation_notification
|
||||
NotificationMailer.send_without_continuation_notification(Dossier.last)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class UserPreview < ActionMailer::Preview
|
||||
class UserMailerPreview < ActionMailer::Preview
|
||||
def new_account_warning
|
||||
UserMailer.new_account_warning(User.first)
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue