From f770ac49070633e752bfb967fa6519f120d8db71 Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 5 Jan 2022 18:02:43 +0100 Subject: [PATCH] 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 --- app/controllers/champs/piece_justificative_controller.rb | 4 +++- .../controllers/champs/piece_justificative_controller_spec.rb | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/champs/piece_justificative_controller.rb b/app/controllers/champs/piece_justificative_controller.rb index cb7c2c822..1eed530b8 100644 --- a/app/controllers/champs/piece_justificative_controller.rb +++ b/app/controllers/champs/piece_justificative_controller.rb @@ -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 diff --git a/spec/controllers/champs/piece_justificative_controller_spec.rb b/spec/controllers/champs/piece_justificative_controller_spec.rb index b279733b7..700ca9ce9 100644 --- a/spec/controllers/champs/piece_justificative_controller_spec.rb +++ b/spec/controllers/champs/piece_justificative_controller_spec.rb @@ -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