Merge pull request #7330 from tchak/fix-dossier-delete-redirect
fix(dossier): redirect on destroyed dossier -> NotFound
This commit is contained in:
commit
c933936aad
2 changed files with 20 additions and 1 deletions
|
@ -8,6 +8,7 @@ module Instructeurs
|
||||||
include ActionController::Streaming
|
include ActionController::Streaming
|
||||||
include Zipline
|
include Zipline
|
||||||
|
|
||||||
|
before_action :redirect_on_dossier_not_found, only: :show
|
||||||
after_action :mark_demande_as_read, only: :show
|
after_action :mark_demande_as_read, only: :show
|
||||||
after_action :mark_messagerie_as_read, only: [:messagerie, :create_commentaire]
|
after_action :mark_messagerie_as_read, only: [:messagerie, :create_commentaire]
|
||||||
after_action :mark_avis_as_read, only: [:avis, :create_avis]
|
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 n’est pas possible de le passer #{dossier_display_state(target_state, lower: true)}."
|
"Le dossier est en ce moment #{dossier_display_state(exception.originating_state, lower: true)} : il n’est pas possible de le passer #{dossier_display_state(target_state, lower: true)}."
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -69,12 +69,24 @@ describe 'Instructing a dossier:', js: true do
|
||||||
|
|
||||||
click_on procedure.libelle
|
click_on procedure.libelle
|
||||||
click_on 'traité'
|
click_on 'traité'
|
||||||
click_on 'Actions'
|
click_on 'Actions' # destroy from list
|
||||||
click_on 'Supprimer le dossier'
|
click_on 'Supprimer le dossier'
|
||||||
click_on 'traité'
|
click_on 'traité'
|
||||||
expect(page).not_to have_button('Actions')
|
expect(page).not_to have_button('Actions')
|
||||||
end
|
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
|
scenario 'A instructeur can follow/unfollow a dossier' do
|
||||||
log_in(instructeur.email, password)
|
log_in(instructeur.email, password)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue