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:
commit
4c65e49950
2 changed files with 20 additions and 1 deletions
|
@ -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
|
||||
|
|
16
spec/controllers/users/transfers_controller_spec.rb
Normal file
16
spec/controllers/users/transfers_controller_spec.rb
Normal 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
|
Loading…
Reference in a new issue