mailers: add tests for dossier_mailer
This commit is contained in:
parent
7e18f662c8
commit
d6624aeca7
2 changed files with 45 additions and 0 deletions
9
spec/factories/deleted_dossier.rb
Normal file
9
spec/factories/deleted_dossier.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
FactoryBot.define do
|
||||
factory :deleted_dossier do
|
||||
dossier_id 1111
|
||||
state 'en_construction'
|
||||
deleted_at DateTime.now
|
||||
|
||||
association :procedure, :published
|
||||
end
|
||||
end
|
36
spec/mailers/dossier_mailer_spec.rb
Normal file
36
spec/mailers/dossier_mailer_spec.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe DossierMailer, type: :mailer do
|
||||
let(:to_email) { 'gestionnaire@exemple.gouv.fr' }
|
||||
|
||||
describe '.notify_deletion_to_user' do
|
||||
let(:deleted_dossier) { build(:deleted_dossier) }
|
||||
|
||||
subject { described_class.notify_deletion_to_user(deleted_dossier, to_email) }
|
||||
|
||||
it { expect(subject.subject).to eq("Votre dossier n° #{deleted_dossier.dossier_id} a bien été supprimé") }
|
||||
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é") }
|
||||
end
|
||||
|
||||
describe '.notify_deletion_to_administration' do
|
||||
let(:deleted_dossier) { build(:deleted_dossier) }
|
||||
|
||||
subject { described_class.notify_deletion_to_administration(deleted_dossier, to_email) }
|
||||
|
||||
it { expect(subject.subject).to eq("Le dossier n° #{deleted_dossier.dossier_id} a été supprimé à la demande de l'usager") }
|
||||
it { expect(subject.body).to include("À la demande de l'usager") }
|
||||
it { expect(subject.body).to include(deleted_dossier.dossier_id) }
|
||||
end
|
||||
|
||||
describe '.notify_unhide_to_user' do
|
||||
let(:dossier) { create(:dossier) }
|
||||
|
||||
subject { described_class.notify_unhide_to_user(dossier) }
|
||||
|
||||
it { expect(subject.subject).to eq("Votre dossier n° #{dossier.id} n'a pas pu être supprimé") }
|
||||
it { expect(subject.body).to include(dossier.id) }
|
||||
it { expect(subject.body).to include("n'a pas pu être supprimé") }
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue