Ask confirmation to delete content blocks from the edit page

We were already doing that when deleting content blocks from the index
page, and we also ask for confirmation in almost every page in the admin
section.
This commit is contained in:
Javi Martín
2024-03-06 14:06:51 +01:00
parent 5a7021396e
commit 6a2ee921de
2 changed files with 4 additions and 1 deletions

View File

@@ -9,6 +9,7 @@
@content_block, @content_block,
text: t("admin.site_customization.content_blocks.index.delete"), text: t("admin.site_customization.content_blocks.index.delete"),
path: (@is_heading_content_block ? admin_site_customization_delete_heading_content_block_path(@content_block.id) : admin_site_customization_content_block_path(@content_block)), path: (@is_heading_content_block ? admin_site_customization_delete_heading_content_block_path(@content_block.id) : admin_site_customization_content_block_path(@content_block)),
confirm: true,
method: :delete, method: :delete,
class: "delete float-right" class: "delete float-right"
) %> ) %>

View File

@@ -103,7 +103,9 @@ describe "Admin custom content blocks", :admin do
block = create(:site_customization_content_block) block = create(:site_customization_content_block)
visit edit_admin_site_customization_content_block_path(block) visit edit_admin_site_customization_content_block_path(block)
click_button "Delete block" accept_confirm("Are you sure? This action will delete \"#{block.name}\" and can't be undone.") do
click_button "Delete block"
end
expect(page).not_to have_content("#{block.name} (#{block.locale})") expect(page).not_to have_content("#{block.name} (#{block.locale})")
expect(page).not_to have_content(block.body) expect(page).not_to have_content(block.body)