fix(users/champs/piece_justificative#update): ensure to bump dossier.last_champ_updated_at otherwise instructeurs are not notified when user update their piece_justificative

This commit is contained in:
Martin 2022-01-05 18:02:43 +01:00
parent dbfb08a052
commit f770ac4907
2 changed files with 7 additions and 1 deletions

View file

@ -14,7 +14,9 @@ class Champs::PieceJustificativeController < ApplicationController
def attach_piece_justificative
@champ = policy_scope(Champ).find(params[:champ_id])
@champ.piece_justificative_file.attach(params[:blob_signed_id])
@champ.save
save_succeed = @champ.save
@champ.dossier.update(last_champ_updated_at: Time.zone.now.utc) if save_succeed
save_succeed
end
def attach_piece_justificative_or_retry

View file

@ -31,6 +31,10 @@ describe Champs::PieceJustificativeController, type: :controller do
expect(response.status).to eq(200)
expect(response.body).to include("##{champ.input_group_id}")
end
it 'updates dossier.last_champ_updated_at' do
expect { subject }.to change { dossier.reload.last_champ_updated_at }
end
end
context 'when the file is invalid' do