Use a button to destroy content blocks from the edit page
We were already using button to destroy content blocks from the content blocks index. As mentioned in commits5311daadfandbb958daf0, using links combined with JavaScript to generate POST (or, in this case, DELETE) requests to the server has a few issues.
This commit is contained in:
@@ -4,10 +4,14 @@
|
||||
|
||||
<%= back_link_to admin_site_customization_content_blocks_path %>
|
||||
|
||||
<%= link_to t("admin.site_customization.content_blocks.index.delete"),
|
||||
(@is_heading_content_block ? admin_site_customization_delete_heading_content_block_path(@content_block.id) : admin_site_customization_content_block_path(@content_block)),
|
||||
method: :delete,
|
||||
class: "delete float-right" %>
|
||||
<%= render Admin::ActionComponent.new(
|
||||
:destroy,
|
||||
@content_block,
|
||||
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)),
|
||||
method: :delete,
|
||||
class: "delete float-right"
|
||||
) %>
|
||||
|
||||
<div class="small-12 column">
|
||||
<h2><%= t("admin.site_customization.content_blocks.edit.title") %></h2>
|
||||
|
||||
@@ -103,7 +103,7 @@ describe "Admin custom content blocks", :admin do
|
||||
block = create(:site_customization_content_block)
|
||||
visit edit_admin_site_customization_content_block_path(block)
|
||||
|
||||
click_link "Delete block"
|
||||
click_button "Delete block"
|
||||
|
||||
expect(page).not_to have_content("#{block.name} (#{block.locale})")
|
||||
expect(page).not_to have_content(block.body)
|
||||
|
||||
Reference in New Issue
Block a user