Merge pull request #3746 from betagouv/fix-last-week-overview-mailer
Technique : corrige une exception dans les récapitulatifs hebdomadaires
This commit is contained in:
commit
04775582fc
2 changed files with 15 additions and 3 deletions
|
@ -21,11 +21,13 @@ class GestionnaireMailer < ApplicationMailer
|
|||
|
||||
def last_week_overview(gestionnaire)
|
||||
email = gestionnaire.email
|
||||
@overview = gestionnaire.last_week_overview
|
||||
headers['X-mailjet-campaign'] = 'last_week_overview'
|
||||
@subject = 'Votre activité hebdomadaire'
|
||||
@overview = gestionnaire.last_week_overview
|
||||
|
||||
mail(to: email, subject: @subject)
|
||||
if @overview.present?
|
||||
headers['X-mailjet-campaign'] = 'last_week_overview'
|
||||
mail(to: email, subject: @subject)
|
||||
end
|
||||
end
|
||||
|
||||
def send_dossier(sender, dossier, recipient)
|
||||
|
|
|
@ -35,5 +35,15 @@ RSpec.describe GestionnaireMailer, type: :mailer do
|
|||
subject { described_class.last_week_overview(gestionnaire) }
|
||||
|
||||
it { expect(subject.body).to include('Votre activité hebdomadaire') }
|
||||
|
||||
context 'when the gestionnaire has no active procedures' do
|
||||
let(:procedure) { nil }
|
||||
let(:last_week_overview) { nil }
|
||||
|
||||
it 'doesn’t send the email' do
|
||||
expect(subject.message).to be_kind_of(ActionMailer::Base::NullMail)
|
||||
expect(subject.body).to be_blank
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue