Merge pull request #7330 from tchak/fix-dossier-delete-redirect

fix(dossier): redirect on destroyed dossier -> NotFound
This commit is contained in:
Paul Chavard 2022-05-17 11:46:33 +02:00 committed by GitHub
commit c933936aad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View file

@ -8,6 +8,7 @@ module Instructeurs
include ActionController::Streaming
include Zipline
before_action :redirect_on_dossier_not_found, only: :show
after_action :mark_demande_as_read, only: :show
after_action :mark_messagerie_as_read, only: [:messagerie, :create_commentaire]
after_action :mark_avis_as_read, only: [:avis, :create_avis]
@ -301,5 +302,11 @@ module Instructeurs
"Le dossier est en ce moment #{dossier_display_state(exception.originating_state, lower: true)} : il nest pas possible de le passer #{dossier_display_state(target_state, lower: true)}."
end
end
def redirect_on_dossier_not_found
if !current_instructeur.dossiers.visible_by_administration.exists?(id: params[:dossier_id])
redirect_to instructeur_procedure_path(procedure)
end
end
end
end

View file

@ -69,12 +69,24 @@ describe 'Instructing a dossier:', js: true do
click_on procedure.libelle
click_on 'traité'
click_on 'Actions'
click_on 'Actions' # destroy from list
click_on 'Supprimer le dossier'
click_on 'traité'
expect(page).not_to have_button('Actions')
end
scenario 'An instructeur can destroy a dossier from view' do
log_in(instructeur.email, password)
dossier.passer_en_instruction(instructeur: instructeur)
dossier.accepter!(instructeur: instructeur)
visit instructeur_dossier_path(procedure, dossier)
click_on 'Actions' # destroy from view
within '.user-dossier-actions' do
click_on 'Supprimer le dossier'
end
end
scenario 'A instructeur can follow/unfollow a dossier' do
log_in(instructeur.email, password)