From 62aad851bf6c94e256b5d2824ec4f2a74c638b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 6 Mar 2024 14:07:39 +0100 Subject: [PATCH] Use icons as links to edit content blocks Just like we do with the rest of the tables in the admin section. --- .../content_blocks/index.html.erb | 8 ++++---- .../site_customization/content_blocks_spec.rb | 16 +++++++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/views/admin/site_customization/content_blocks/index.html.erb b/app/views/admin/site_customization/content_blocks/index.html.erb index 03fd96248..05cda15a7 100644 --- a/app/views/admin/site_customization/content_blocks/index.html.erb +++ b/app/views/admin/site_customization/content_blocks/index.html.erb @@ -34,21 +34,21 @@ <% @content_blocks.each do |content_block| %> - <%= link_to "#{content_block.name} (#{content_block.locale})", edit_admin_site_customization_content_block_path(content_block) %> + <%= "#{content_block.name} (#{content_block.locale})" %> <%= raw content_block.body %> - <%= render Admin::TableActionsComponent.new(content_block, actions: [:destroy]) %> + <%= render Admin::TableActionsComponent.new(content_block) %> <% end %> <% @headings_content_blocks.each do |content_block| %> - <%= link_to "#{content_block.name} (#{content_block.locale})", admin_site_customization_edit_heading_content_block_path(content_block) %> + <%= "#{content_block.name} (#{content_block.locale})" %> <%= raw content_block.body %> <%= 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) ) %> diff --git a/spec/system/admin/site_customization/content_blocks_spec.rb b/spec/system/admin/site_customization/content_blocks_spec.rb index abbefc138..012fc28ee 100644 --- a/spec/system/admin/site_customization/content_blocks_spec.rb +++ b/spec/system/admin/site_customization/content_blocks_spec.rb @@ -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"