Merge pull request #6802 from betagouv/US/fix_notifications_regarding_update_champs_piece_justificative

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:
mfo 2022-01-06 13:14:06 +01:00 committed by GitHub
commit ad91ed362c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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