2016-12-15 17:59:01 +01:00
|
|
|
require "spec_helper"
|
2015-12-15 11:02:07 +01:00
|
|
|
|
|
|
|
RSpec.describe NotificationMailer, type: :mailer do
|
2017-03-05 20:20:29 +01:00
|
|
|
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
|
|
|
|
|
2015-12-15 11:02:07 +01:00
|
|
|
describe ".new_answer" do
|
|
|
|
let(:user) { create(:user) }
|
2016-02-04 14:08:35 +01:00
|
|
|
let(:dossier) { create(:dossier, user: user) }
|
2015-12-15 11:02:07 +01:00
|
|
|
|
|
|
|
subject(:subject) { described_class.new_answer(dossier) }
|
|
|
|
|
2017-01-03 11:36:08 +01:00
|
|
|
it { expect(subject.body).to match('Un nouveau message est disponible dans votre espace TPS.') }
|
2015-12-15 15:33:21 +01:00
|
|
|
it { expect(subject.body).to include("Pour le consulter, merci de vous rendre sur #{users_dossier_recapitulatif_url(dossier_id: dossier.id)}") }
|
2017-01-03 11:36:08 +01:00
|
|
|
it { expect(subject.subject).to eq("Nouveau message pour votre dossier TPS N°#{dossier.id}") }
|
2015-12-15 11:02:07 +01:00
|
|
|
end
|
2015-12-15 11:41:50 +01:00
|
|
|
|
2015-12-17 10:06:40 +01:00
|
|
|
describe ".dossier_submitted" do
|
|
|
|
let(:user) { create(:user) }
|
2016-02-04 14:08:35 +01:00
|
|
|
let(:dossier) { create(:dossier, user: user) }
|
2015-12-17 10:06:40 +01:00
|
|
|
|
|
|
|
subject(:subject) { described_class.dossier_submitted(dossier) }
|
|
|
|
|
2017-02-06 16:52:57 +01:00
|
|
|
before { dossier.reload }
|
|
|
|
|
2015-12-17 10:06:40 +01:00
|
|
|
it { expect(subject.body).to match("Nous vous confirmons que votre dossier N°#{dossier.id} a été déposé") }
|
2016-08-30 11:18:43 +02:00
|
|
|
it { expect(subject.body).to match("auprès de #{dossier.procedure.organisation} avec succès") }
|
2015-12-17 10:06:40 +01:00
|
|
|
it { expect(subject.body).to match("ce jour à #{dossier.updated_at}.") }
|
|
|
|
it { expect(subject.subject).to eq("Votre dossier TPS N°#{dossier.id} a été déposé") }
|
|
|
|
end
|
2015-12-15 11:02:07 +01:00
|
|
|
end
|