tests
This commit is contained in:
parent
e824118aea
commit
30df608a99
3 changed files with 34 additions and 10 deletions
|
@ -5,7 +5,7 @@ describe Instructeurs::AvisController, type: :controller do
|
|||
let(:now) { Time.zone.parse('01/02/2345') }
|
||||
let(:expert) { create(:expert) }
|
||||
let(:claimant) { create(:instructeur) }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure) }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure, notify_on_new_avis: false) }
|
||||
let(:instructeur) { create(:instructeur) }
|
||||
let(:procedure) { create(:procedure, :published, instructeurs: [instructeur]) }
|
||||
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
||||
|
|
|
@ -826,6 +826,13 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
it { expect(saved_avis.expert.email).to eq("titi@titimail.com") }
|
||||
end
|
||||
|
||||
context 'when the expert do not want to receive notification' do
|
||||
let(:emails) { "[\"email@a.com\"]" }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: dossier.procedure, notify_on_new_avis: false) }
|
||||
|
||||
before { subject }
|
||||
end
|
||||
|
||||
context 'with linked dossiers' do
|
||||
let(:asked_confidentiel) { false }
|
||||
let(:previous_avis_confidentiel) { false }
|
||||
|
|
|
@ -1197,12 +1197,13 @@ describe Users::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'email notification to experts' do
|
||||
context 'notify on new message to experts' do
|
||||
let(:expert) { create(:expert) }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure) }
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure, notify_on_new_message: true) }
|
||||
let(:avis) { create(:avis, dossier: dossier, claimant: instructeur_with_instant_message, experts_procedure: experts_procedure) }
|
||||
let(:avis2) { create(:avis, dossier: dossier, claimant: instructeur_with_instant_message, experts_procedure: experts_procedure) }
|
||||
|
||||
context 'when notify_on_new_message is true' do
|
||||
before do
|
||||
allow(AvisMailer).to receive(:notify_new_commentaire_to_expert).and_return(double(deliver_later: nil))
|
||||
avis
|
||||
|
@ -1215,6 +1216,22 @@ describe Users::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when notify_on_new_message is false' do
|
||||
let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: procedure, notify_on_new_message: false) }
|
||||
|
||||
before do
|
||||
allow(AvisMailer).to receive(:notify_new_commentaire_to_expert).and_return(double(deliver_later: nil))
|
||||
avis
|
||||
avis2
|
||||
subject
|
||||
end
|
||||
|
||||
it 'does not send any email to the expert' do
|
||||
expect(AvisMailer).not_to have_received(:notify_new_commentaire_to_expert)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'notification' do
|
||||
before 'instructeurs have no notification before the message' do
|
||||
expect(instructeur_with_instant_message.followed_dossiers.with_notifications).to eq([])
|
||||
|
|
Loading…
Reference in a new issue