From 22034730b0c9a4070cd9a51a025be8ac41f4ea75 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 11 Apr 2019 12:23:40 +0200 Subject: [PATCH 1/2] Fix factory to avoid crash because of procedure is nil --- spec/factories/dossier.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/factories/dossier.rb b/spec/factories/dossier.rb index 41b50f313..f3d6b2546 100644 --- a/spec/factories/dossier.rb +++ b/spec/factories/dossier.rb @@ -19,7 +19,7 @@ FactoryBot.define do end trait :with_service do - after(:build) do |dossier, _evaluator| + after(:create) do |dossier, _evaluator| dossier.procedure.service = create(:service) end end From 1a97cd42de15128005a3bacbcf4525265d602b8d Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 11 Apr 2019 12:23:40 +0200 Subject: [PATCH 2/2] Fix missing helper in notification mailer --- app/mailers/notification_mailer.rb | 2 ++ spec/mailers/notification_mailer_spec.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb index 767a521b3..3ed99794e 100644 --- a/app/mailers/notification_mailer.rb +++ b/app/mailers/notification_mailer.rb @@ -6,6 +6,8 @@ # The subject and body of a Notification can be customized by each demarche. # class NotificationMailer < ApplicationMailer + helper ServiceHelper + def send_dossier_received(dossier) send_notification(dossier, dossier.procedure.received_mail_template) end diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb index 1d6702ffb..219cbcae8 100644 --- a/spec/mailers/notification_mailer_spec.rb +++ b/spec/mailers/notification_mailer_spec.rb @@ -13,7 +13,7 @@ RSpec.describe NotificationMailer, type: :mailer do end let(:user) { create(:user) } - let(:dossier) { create(:dossier, user: user) } + let(:dossier) { create(:dossier, :with_service, user: user) } describe '.send_notification' do let(:email_template) { instance_double('email_template', subject_for_dossier: 'subject', body_for_dossier: 'body') }