Use icons as links to edit content blocks

Just like we do with the rest of the tables in the admin section.
This commit is contained in:
Javi Martín
2024-03-06 14:07:39 +01:00
parent 6a2ee921de
commit 62aad851bf
2 changed files with 15 additions and 9 deletions

View File

@@ -34,21 +34,21 @@
<tbody>
<% @content_blocks.each do |content_block| %>
<tr id="<%= dom_id(content_block) %>">
<td><%= link_to "#{content_block.name} (#{content_block.locale})", edit_admin_site_customization_content_block_path(content_block) %></td>
<td><%= "#{content_block.name} (#{content_block.locale})" %></td>
<td><%= raw content_block.body %></td>
<td>
<%= render Admin::TableActionsComponent.new(content_block, actions: [:destroy]) %>
<%= render Admin::TableActionsComponent.new(content_block) %>
</td>
</tr>
<% end %>
<% @headings_content_blocks.each do |content_block| %>
<tr id="<%= dom_id(content_block) %>">
<td><%= link_to "#{content_block.name} (#{content_block.locale})", admin_site_customization_edit_heading_content_block_path(content_block) %></td>
<td><%= "#{content_block.name} (#{content_block.locale})" %></td>
<td><%= raw content_block.body %></td>
<td>
<%= render Admin::TableActionsComponent.new(
content_block,
actions: [:destroy],
edit_path: admin_site_customization_edit_heading_content_block_path(content_block),
destroy_path: admin_site_customization_delete_heading_content_block_path(content_block)
) %>
</td>

View File

@@ -2,13 +2,19 @@ require "rails_helper"
describe "Admin custom content blocks", :admin do
scenario "Index" do
block = create(:site_customization_content_block)
heading_block = create(:heading_content_block)
block = create(:site_customization_content_block, name: "top_links")
heading_block = create(:heading_content_block, heading: create(:budget_heading, name: "Reforestation"))
visit admin_site_customization_content_blocks_path
expect(page).to have_content(block.name)
within "tr", text: "top_links" do
expect(page).to have_link "Edit"
end
within "tr", text: "Reforestation" do
expect(page).to have_link "Edit"
end
expect(page).to have_content(block.body)
expect(page).to have_content(heading_block.heading.name)
expect(page).to have_content(heading_block.body)
end
@@ -73,7 +79,7 @@ describe "Admin custom content blocks", :admin do
click_link "Custom content blocks"
end
click_link "top_links (en)"
within("tr", text: "top_links (en)") { click_link "Edit" }
fill_in "site_customization_content_block_body", with: "Some other custom content"
click_button "Update Custom content block"