From 58767383699bd0ce734725f72fcdba2ef490c582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 6 Mar 2024 05:00:03 +0100 Subject: [PATCH] Ask confirmation to delete drafts and questions This is similar to what we do in almost every other page of the admin section. --- app/views/admin/legislation/draft_versions/edit.html.erb | 1 + app/views/admin/legislation/questions/edit.html.erb | 1 + spec/system/admin/legislation/draft_versions_spec.rb | 5 ++++- spec/system/admin/legislation/questions_spec.rb | 4 +++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/views/admin/legislation/draft_versions/edit.html.erb b/app/views/admin/legislation/draft_versions/edit.html.erb index a9fadfdc8..efdde4e27 100644 --- a/app/views/admin/legislation/draft_versions/edit.html.erb +++ b/app/views/admin/legislation/draft_versions/edit.html.erb @@ -19,6 +19,7 @@ :destroy, @draft_version, method: :delete, + confirm: true, class: "button hollow alert" ) %> diff --git a/app/views/admin/legislation/questions/edit.html.erb b/app/views/admin/legislation/questions/edit.html.erb index c98ce4eaf..ec51522ab 100644 --- a/app/views/admin/legislation/questions/edit.html.erb +++ b/app/views/admin/legislation/questions/edit.html.erb @@ -19,6 +19,7 @@ :destroy, @question, method: :delete, + confirm: true, class: "button hollow alert" ) %> diff --git a/spec/system/admin/legislation/draft_versions_spec.rb b/spec/system/admin/legislation/draft_versions_spec.rb index 2e5f8034e..642a91f58 100644 --- a/spec/system/admin/legislation/draft_versions_spec.rb +++ b/spec/system/admin/legislation/draft_versions_spec.rb @@ -78,7 +78,10 @@ describe "Admin legislation draft versions", :admin do version = create(:legislation_draft_version, body: "Version 1") visit edit_admin_legislation_process_draft_version_path(version.process, version) - click_button "Delete" + + accept_confirm("Are you sure? This action will delete \"Version 1\" and can't be undone.") do + click_button "Delete" + end expect(page).to have_content "Draft deleted successfully" end diff --git a/spec/system/admin/legislation/questions_spec.rb b/spec/system/admin/legislation/questions_spec.rb index 20c8fb1a7..45b39d088 100644 --- a/spec/system/admin/legislation/questions_spec.rb +++ b/spec/system/admin/legislation/questions_spec.rb @@ -75,7 +75,9 @@ describe "Admin legislation questions", :admin do visit edit_admin_legislation_process_question_path(process, question) - click_button "Delete" + accept_confirm("Are you sure? This action will delete \"Question 2\" and can't be undone.") do + click_button "Delete" + end expect(page).to have_content "Questions" expect(page).to have_content "Question 1"