From f1f7f0ef9fe0b31f107a64f74273028debc2532d Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 24 Jan 2019 15:38:34 +0000 Subject: [PATCH] specs: cleanup "Delete draft from dossiers list" spec --- app/views/new_user/dossiers/index.html.haml | 2 +- spec/features/new_user/list_dossiers_spec.rb | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/new_user/dossiers/index.html.haml b/app/views/new_user/dossiers/index.html.haml index 347961d81..0c83b7eeb 100644 --- a/app/views/new_user/dossiers/index.html.haml +++ b/app/views/new_user/dossiers/index.html.haml @@ -52,7 +52,7 @@ = dossier.updated_at.strftime("%d/%m/%Y") %td.action-col.delete-col - if dossier.brouillon? - = link_to(ask_deletion_dossier_path(dossier), method: :post, class: 'button danger', data: { disable: true, confirm: "En continuant, vous allez supprimer ce dossier ainsi que les informations qu’il contient. Toute suppression entraine l’annulation de la démarche en cours.\n\nConfirmer la suppression ?" }) do + = link_to(ask_deletion_dossier_path(dossier), method: :post, class: 'button danger', data: { disable: true, confirm: "En continuant, vous allez supprimer ce dossier ainsi que les informations qu’il contient. Toute suppression entraine l’annulation de la démarche en cours.\n\nConfirmer la suppression ?" }) do %span.icon.delete Supprimer = paginate(@dossiers) diff --git a/spec/features/new_user/list_dossiers_spec.rb b/spec/features/new_user/list_dossiers_spec.rb index 3e36e97d8..f47133bac 100644 --- a/spec/features/new_user/list_dossiers_spec.rb +++ b/spec/features/new_user/list_dossiers_spec.rb @@ -49,13 +49,13 @@ describe 'user access to the list of his dossier' do expect(page).not_to have_link(nil, href: ask_deletion_dossier_path(dossier1)) end - context 'when user clicks on delete brouillon list', js: true do - before do - find(:xpath, "//a[@href='#{ask_deletion_dossier_path(dossier_brouillon)}']").click - page.driver.browser.switch_to.alert.accept - end + context 'when user clicks on delete brouillon', js: true do scenario 'dossier is deleted' do - expect(page).not_to have_link("Supprimer", href: dossier_brouillon.procedure.libelle) + page.accept_alert('Confirmer la suppression ?') do + find(:xpath, "//a[@href='#{ask_deletion_dossier_path(dossier_brouillon)}']").click + end + + expect(page).to have_content('Votre dossier a bien été supprimé.') end end