refactor(mail.delay): use simplier implementation using after_action to prevent email delivery with delay
This commit is contained in:
parent
e48b6e0c1f
commit
8bbd77f89f
6 changed files with 29 additions and 48 deletions
|
@ -28,8 +28,8 @@ RSpec.describe DossierMailer, type: :mailer do
|
|||
|
||||
describe '.notify_new_answer with dossier brouillon' do
|
||||
let(:dossier) { create(:dossier, procedure: build(:simple_procedure)) }
|
||||
|
||||
subject { described_class.notify_new_answer(dossier) }
|
||||
let(:commentaire) { create(:commentaire, dossier: dossier) }
|
||||
subject { described_class.with(commentaire: commentaire).notify_new_answer }
|
||||
|
||||
it { expect(subject.subject).to include("Nouveau message") }
|
||||
it { expect(subject.subject).to include(dossier.id.to_s) }
|
||||
|
@ -40,8 +40,8 @@ RSpec.describe DossierMailer, type: :mailer do
|
|||
|
||||
describe '.notify_new_answer with dossier en construction' do
|
||||
let(:dossier) { create(:dossier, state: "en_construction", procedure: build(:simple_procedure)) }
|
||||
|
||||
subject { described_class.notify_new_answer(dossier) }
|
||||
let(:commentaire) { create(:commentaire, dossier: dossier) }
|
||||
subject { described_class.with(commentaire: commentaire).notify_new_answer }
|
||||
|
||||
it { expect(subject.subject).to include("Nouveau message") }
|
||||
it { expect(subject.subject).to include(dossier.id.to_s) }
|
||||
|
@ -50,6 +50,15 @@ RSpec.describe DossierMailer, type: :mailer do
|
|||
it_behaves_like 'a dossier notification'
|
||||
end
|
||||
|
||||
describe '.notify_new_answer with commentaire discarded' do
|
||||
let(:dossier) { create(:dossier, procedure: build(:simple_procedure)) }
|
||||
let(:commentaire) { create(:commentaire, dossier: dossier, discarded_at: 2.minutes.ago) }
|
||||
|
||||
subject { described_class.with(commentaire: commentaire).notify_new_answer }
|
||||
|
||||
it { expect(subject.perform_deliveries).to be_falsy }
|
||||
end
|
||||
|
||||
describe '.notify_deletion_to_user' do
|
||||
let(:deleted_dossier) { build(:deleted_dossier) }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue