Merge pull request #8966 from mfo/US/fix-avis-remind-with-question
ETQ instructeur, je peux relancer une demande d'avis meme si celui ci contient une question
This commit is contained in:
commit
1a704f0479
2 changed files with 22 additions and 7 deletions
|
@ -111,7 +111,7 @@ class Avis < ApplicationRecord
|
|||
|
||||
def remind_by!(revocator)
|
||||
return false if !remindable_by?(revocator) || answer.present?
|
||||
update!(reminded_at: Time.zone.now)
|
||||
update_column(:reminded_at, Time.zone.now)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -9,12 +9,13 @@ describe Instructeurs::AvisController, type: :controller do
|
|||
let(:instructeur) { create(:instructeur) }
|
||||
let(:procedure) { create(:procedure, :published, instructeurs: [instructeur]) }
|
||||
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
||||
let!(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure) }
|
||||
let!(:avis_without_answer) { create(:avis, dossier: dossier, claimant: claimant, experts_procedure: experts_procedure) }
|
||||
|
||||
before { sign_in(instructeur.user) }
|
||||
|
||||
describe "#revoker" do
|
||||
let!(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure) }
|
||||
|
||||
before do
|
||||
patch :revoquer, params: { procedure_id: procedure.id, id: avis.id }
|
||||
end
|
||||
|
@ -28,12 +29,26 @@ describe Instructeurs::AvisController, type: :controller do
|
|||
before do
|
||||
allow(AvisMailer).to receive(:avis_invitation).and_return(double(deliver_later: nil))
|
||||
end
|
||||
context 'without question' do
|
||||
let!(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure) }
|
||||
|
||||
it 'sends a reminder to the expert' do
|
||||
get :remind, params: { procedure_id: procedure.id, id: avis.id }
|
||||
expect(AvisMailer).to have_received(:avis_invitation).once.with(avis)
|
||||
expect(flash.notice).to eq("Un mail de relance a été envoyé à #{avis.expert.email}")
|
||||
expect(avis.reload.reminded_at).to be_present
|
||||
it 'sends a reminder to the expert' do
|
||||
get :remind, params: { procedure_id: procedure.id, id: avis.id }
|
||||
expect(AvisMailer).to have_received(:avis_invitation).once.with(avis)
|
||||
expect(flash.notice).to eq("Un mail de relance a été envoyé à #{avis.expert.email}")
|
||||
expect(avis.reload.reminded_at).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
context 'with question' do
|
||||
let!(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure, question_label: '123') }
|
||||
|
||||
it 'sends a reminder to the expert' do
|
||||
get :remind, params: { procedure_id: procedure.id, id: avis.id }
|
||||
expect(AvisMailer).to have_received(:avis_invitation).once.with(avis)
|
||||
expect(flash.notice).to eq("Un mail de relance a été envoyé à #{avis.expert.email}")
|
||||
expect(avis.reload.reminded_at).to be_present
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue