From b8706757e3d03bb05d300b0084c311eba9d750b5 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 24 Jun 2020 17:25:32 +0200 Subject: [PATCH] controllers: disable explicit purge of invalid file --- app/controllers/champs/piece_justificative_controller.rb | 6 ------ .../champs/piece_justificative_controller_spec.rb | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/app/controllers/champs/piece_justificative_controller.rb b/app/controllers/champs/piece_justificative_controller.rb index 3aa6578b7..8961dfae6 100644 --- a/app/controllers/champs/piece_justificative_controller.rb +++ b/app/controllers/champs/piece_justificative_controller.rb @@ -9,12 +9,6 @@ class Champs::PieceJustificativeController < ApplicationController render :show else errors = @champ.errors.full_messages - - # Before Rails 6, the attachment was persisted to database - # by 'attach', even before calling save. - # So until we're on Rails 6, we need to purge the file explicitely. - @champ.piece_justificative_file.purge_later - render :json => { errors: errors }, :status => 422 end end diff --git a/spec/controllers/champs/piece_justificative_controller_spec.rb b/spec/controllers/champs/piece_justificative_controller_spec.rb index 95bf42095..5c5fa202c 100644 --- a/spec/controllers/champs/piece_justificative_controller_spec.rb +++ b/spec/controllers/champs/piece_justificative_controller_spec.rb @@ -44,7 +44,7 @@ describe Champs::PieceJustificativeController, type: :controller do # See https://github.com/betagouv/demarches-simplifiees.fr/issues/4926 before do champ - expect_any_instance_of(Champs::PieceJustificativeChamp).to receive(:save).and_return(false) + expect_any_instance_of(Champs::PieceJustificativeChamp).to receive(:save).twice.and_return(false) expect_any_instance_of(Champs::PieceJustificativeChamp).to receive(:errors) .and_return(double(full_messages: ['La pièce justificative n’est pas d’un type accepté'])) end