demarches-normaliennes/spec/mailers/dossier_mailer_spec.rb

71 lines
2.8 KiB
Ruby
Raw Normal View History

2018-07-16 14:39:04 +02:00
require "rails_helper"
RSpec.describe DossierMailer, type: :mailer do
let(:to_email) { 'gestionnaire@exemple.gouv.fr' }
shared_examples 'a dossier notification' do
it 'includes the contact informations in the footer' do
expect(subject.body).to include('ne pas répondre')
end
end
describe '.notify_new_draft' do
let(:dossier) { create(:dossier, procedure: build(:simple_procedure)) }
subject { described_class.notify_new_draft(dossier) }
it { expect(subject.subject).to include("brouillon") }
2018-11-20 17:45:50 +01:00
it { expect(subject.subject).to include(dossier.procedure.libelle) }
it { expect(subject.body).to include(dossier.procedure.libelle) }
it { expect(subject.body).to include(dossier_url(dossier)) }
it_behaves_like 'a dossier notification'
end
describe '.notify_new_answer' do
let(:dossier) { create(:dossier, procedure: build(:simple_procedure)) }
subject { described_class.notify_new_answer(dossier) }
it { expect(subject.subject).to include("Nouveau message") }
it { expect(subject.subject).to include(dossier.id.to_s) }
it { expect(subject.body).to include(messagerie_dossier_url(dossier)) }
it_behaves_like 'a dossier notification'
end
2018-07-16 14:39:04 +02:00
describe '.notify_deletion_to_user' do
let(:deleted_dossier) { build(:deleted_dossier) }
subject { described_class.notify_deletion_to_user(deleted_dossier, to_email) }
2019-07-17 13:42:14 +02:00
it { expect(subject.subject).to eq("Votre dossier nº #{deleted_dossier.dossier_id} a bien été supprimé") }
2018-07-16 14:39:04 +02:00
it { expect(subject.body).to include("Votre dossier") }
it { expect(subject.body).to include(deleted_dossier.dossier_id) }
it { expect(subject.body).to include("a bien été supprimé") }
it { expect(subject.body).to include(deleted_dossier.procedure.libelle) }
2018-07-16 14:39:04 +02:00
end
describe '.notify_deletion_to_administration' do
let(:deleted_dossier) { build(:deleted_dossier) }
subject { described_class.notify_deletion_to_administration(deleted_dossier, to_email) }
2019-07-17 13:42:14 +02:00
it { expect(subject.subject).to eq("Le dossier nº #{deleted_dossier.dossier_id} a été supprimé à la demande de l'usager") }
2018-07-16 14:39:04 +02:00
it { expect(subject.body).to include("À la demande de l'usager") }
it { expect(subject.body).to include(deleted_dossier.dossier_id) }
it { expect(subject.body).to include(deleted_dossier.procedure.libelle) }
2018-07-16 14:39:04 +02:00
end
describe '.notify_unhide_to_user' do
let(:dossier) { create(:dossier) }
subject { described_class.notify_unhide_to_user(dossier) }
2019-07-17 13:42:14 +02:00
it { expect(subject.subject).to eq("Votre dossier nº #{dossier.id} n'a pas pu être supprimé") }
2018-07-16 14:39:04 +02:00
it { expect(subject.body).to include(dossier.id) }
it { expect(subject.body).to include("n'a pas pu être supprimé") }
it { expect(subject.body).to include(dossier.procedure.libelle) }
2018-07-16 14:39:04 +02:00
end
end