Merge pull request #6510 from betagouv/fix_6504_transfert_exception

[Fix #6504] Corrige une erreur lors de la suppression d'une demande de transfert de fichier
This commit is contained in:
Paul Chavard 2021-10-04 12:33:19 +02:00 committed by GitHub
commit 4c65e49950
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View file

@ -12,7 +12,10 @@ module Users
end
def destroy
transfer = DossierTransfer.find_by!(id: params[:id], dossiers: { user: current_user })
transfer = DossierTransfer
.joins(:dossiers)
.find_by!(id: params[:id], dossiers: { user: current_user })
transfer.destroy
redirect_to dossiers_path
end

View file

@ -0,0 +1,16 @@
describe Users::TransfersController, type: :controller do
let(:user) { create(:user) }
let(:dossier) { create(:dossier, user: user) }
before { sign_in(user) }
describe 'DELETE destroy' do
let(:dossier_transfert) { DossierTransfer.initiate(user.email, [dossier]) }
before do
delete :destroy, params: { id: dossier_transfert.id }
end
it { expect { dossier_transfert.reload }.to raise_error(ActiveRecord::RecordNotFound) }
end
end