update dossier after saving commentaire
update last_commentaire_updated_at without hook Co-authored-by: Christophe Robillard <christophe.robillard@beta.gouv.fr>
This commit is contained in:
parent
667b7d9876
commit
f3a675c3bc
6 changed files with 18 additions and 0 deletions
|
@ -117,18 +117,23 @@ describe Instructeurs::AvisController, type: :controller do
|
|||
describe '#create_commentaire' do
|
||||
let(:file) { nil }
|
||||
let(:scan_result) { true }
|
||||
let(:now) { Time.zone.parse("14/07/1789") }
|
||||
|
||||
subject { post :create_commentaire, params: { id: avis_without_answer.id, procedure_id: procedure.id, commentaire: { body: 'commentaire body', piece_jointe: file } } }
|
||||
|
||||
before do
|
||||
allow(ClamavService).to receive(:safe_file?).and_return(scan_result)
|
||||
Timecop.freeze(now)
|
||||
end
|
||||
|
||||
after { Timecop.return }
|
||||
|
||||
it do
|
||||
subject
|
||||
|
||||
expect(response).to redirect_to(messagerie_instructeur_avis_path(avis_without_answer.procedure, avis_without_answer))
|
||||
expect(dossier.commentaires.map(&:body)).to match(['commentaire body'])
|
||||
expect(dossier.reload.last_commentaire_updated_at).to eq(now)
|
||||
end
|
||||
|
||||
context "with a file" do
|
||||
|
|
|
@ -390,6 +390,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
let(:body) { "avant\napres" }
|
||||
let(:file) { fixture_file_upload('spec/fixtures/files/piece_justificative_0.pdf', 'application/pdf') }
|
||||
let(:scan_result) { true }
|
||||
let(:now) { Timecop.freeze("09/11/1989") }
|
||||
|
||||
subject {
|
||||
post :create_commentaire, params: {
|
||||
|
@ -404,14 +405,18 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
|
||||
before do
|
||||
allow(ClamavService).to receive(:safe_file?).and_return(scan_result)
|
||||
Timecop.freeze(now)
|
||||
end
|
||||
|
||||
after { Timecop.return }
|
||||
|
||||
it "creates a commentaire" do
|
||||
expect { subject }.to change(Commentaire, :count).by(1)
|
||||
expect(instructeur.followed_dossiers).to include(dossier)
|
||||
|
||||
expect(response).to redirect_to(messagerie_instructeur_dossier_path(dossier.procedure, dossier))
|
||||
expect(flash.notice).to be_present
|
||||
expect(dossier.reload.last_commentaire_updated_at).to eq(now)
|
||||
end
|
||||
|
||||
context "when the commentaire created with virus file" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue