Unify NotificationMailer methods’ signatures

This commit is contained in:
gregoirenovel 2018-05-30 23:55:34 +02:00
parent 7ea37abefa
commit a57e2388f6
4 changed files with 4 additions and 5 deletions

View file

@ -1,8 +1,7 @@
class NotificationMailer < ApplicationMailer
default to: Proc.new { @user.email }
def send_dossier_received(dossier_id)
dossier = Dossier.find(dossier_id)
def send_dossier_received(dossier)
send_notification(dossier, dossier.procedure.received_mail_template)
end

View file

@ -323,7 +323,7 @@ class Dossier < ApplicationRecord
def send_dossier_received
if saved_change_to_state? && en_instruction?
NotificationMailer.send_dossier_received(id).deliver_later
NotificationMailer.send_dossier_received(self).deliver_later
end
end

View file

@ -38,7 +38,7 @@ RSpec.describe NotificationMailer, type: :mailer do
end
describe '.send_dossier_received' do
subject { described_class.send_dossier_received(dossier.id) }
subject { described_class.send_dossier_received(dossier) }
let(:email_template) { create(:received_mail) }
before do

View file

@ -603,7 +603,7 @@ describe Dossier do
it "sends an email when the dossier becomes en_instruction" do
dossier.en_instruction!
expect(NotificationMailer).to have_received(:send_dossier_received).with(dossier.id)
expect(NotificationMailer).to have_received(:send_dossier_received).with(dossier)
end
it "does not an email when the dossier becomes accepte" do