From d85a87a517e8584ee6c6183baaee56c7e8b2bf1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 11 Oct 2024 04:39:32 +0200 Subject: [PATCH] Use a button to delete surveys As mentioned in commit 5311daadf, there are several reasons to use buttons in these situations. And, as mentioned in the previous commits, using buttons instead of links for actions requiring confirmation will help us test for accessibility issues. --- app/assets/stylesheets/dashboard.scss | 8 ++++++++ app/views/dashboard/polls/_poll.html.erb | 10 +++++----- spec/system/dashboard/polls_spec.rb | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/dashboard.scss b/app/assets/stylesheets/dashboard.scss index a9755e38e..60bfe0fb0 100644 --- a/app/assets/stylesheets/dashboard.scss +++ b/app/assets/stylesheets/dashboard.scss @@ -442,6 +442,14 @@ .button { font-weight: bold; } + + button { + cursor: pointer; + + &:hover { + text-decoration: underline; + } + } } .community-poll { diff --git a/app/views/dashboard/polls/_poll.html.erb b/app/views/dashboard/polls/_poll.html.erb index 26fe74c28..4c3eca69d 100644 --- a/app/views/dashboard/polls/_poll.html.erb +++ b/app/views/dashboard/polls/_poll.html.erb @@ -27,10 +27,10 @@ <% end %>

<%= t("dashboard.polls.poll.show_results_help") %>

- <%= link_to t("dashboard.polls.poll.delete"), - proposal_dashboard_poll_path(proposal, poll), - method: :delete, - "data-confirm": t("dashboard.polls.poll.alert_notice"), - class: "delete" %> + <%= button_to t("dashboard.polls.poll.delete"), + proposal_dashboard_poll_path(proposal, poll), + method: :delete, + "data-confirm": t("dashboard.polls.poll.alert_notice"), + class: "delete" %> diff --git a/spec/system/dashboard/polls_spec.rb b/spec/system/dashboard/polls_spec.rb index 0f7d3d61b..0620cdcf3 100644 --- a/spec/system/dashboard/polls_spec.rb +++ b/spec/system/dashboard/polls_spec.rb @@ -199,7 +199,7 @@ describe "Polls" do visit proposal_dashboard_polls_path(proposal) within("#poll_#{poll.id}") do - accept_confirm { click_link "Delete survey" } + accept_confirm { click_button "Delete survey" } end expect(page).to have_content("Survey deleted successfully") @@ -214,7 +214,7 @@ describe "Polls" do visit proposal_dashboard_polls_path(proposal) within("#poll_#{poll.id}") do - accept_confirm { click_link "Delete survey" } + accept_confirm { click_button "Delete survey" } end expect(page).to have_content("You cannot destroy a survey that has responses")