NotificationMailer: add send notification

This commit is contained in:
Simon Lehericey 2017-03-05 20:20:29 +01:00
parent 89763ec8d4
commit 65d399b4b0
2 changed files with 19 additions and 0 deletions

View file

@ -2,6 +2,15 @@ class NotificationMailer < ApplicationMailer
default from: 'tps@apientreprise.fr',
to: Proc.new { @user.email }
def send_notification dossier, email
vars_mailer(dossier)
obj = email.object_for_dossier dossier
body = email.body_for_dossier dossier
mail(subject: obj) { |format| format.html { body } }
end
def new_answer dossier
send_mail dossier, "Nouveau message pour votre dossier TPS N°#{dossier.id}"
end

View file

@ -1,6 +1,16 @@
require "spec_helper"
RSpec.describe NotificationMailer, type: :mailer do
describe '.send_notification' do
let(:user) { create(:user) }
let(:dossier) { create(:dossier, user: user) }
let(:email) { instance_double('email', object_for_dossier: 'object', body_for_dossier: 'body') }
subject { described_class.send_notification(dossier, email) }
it { expect(subject.subject).to eq(email.object_for_dossier) }
it { expect(subject.body).to eq(email.body_for_dossier) }
end
describe ".new_answer" do
let(:user) { create(:user) }
let(:dossier) { create(:dossier, user: user) }