diff --git a/app/components/proposals/votes_component.html.erb b/app/components/proposals/votes_component.html.erb index e6302e481..667a92fb0 100644 --- a/app/components/proposals/votes_component.html.erb +++ b/app/components/proposals/votes_component.html.erb @@ -6,17 +6,16 @@
<%= t("proposals.proposal.already_supported") %>
- <% elsif can_vote? %> - <%= link_to t("proposals.proposal.support"), vote_url, + <% else %> + <%= button_to vote_url, class: "button button-support small expanded", title: t("proposals.proposal.support_title"), method: "post", remote: true, - "aria-label": support_aria_label%> - <% else %> -
+ disabled: !can_vote?, + "aria-label": support_aria_label do %> <%= t("proposals.proposal.support") %> -
+ <% end %> <% end %> diff --git a/spec/components/proposals/votes_component_spec.rb b/spec/components/proposals/votes_component_spec.rb index 51b7a769e..ef686e625 100644 --- a/spec/components/proposals/votes_component_spec.rb +++ b/spec/components/proposals/votes_component_spec.rb @@ -4,14 +4,13 @@ describe Proposals::VotesComponent do let(:proposal) { create(:proposal, title: "Create a monthly transport ticket") } let(:component) { Proposals::VotesComponent.new(proposal) } - describe "support proposal link" do - it "is shown as plain text to unverified users" do + describe "support proposal button" do + it "is disabled to unverified users" do sign_in(create(:user)) render_inline component - expect(page).to have_content "Support" - expect(page).not_to have_link "Support" + expect(page).to have_button "Support", disabled: true end it "is shown to verified users" do @@ -19,9 +18,9 @@ describe Proposals::VotesComponent do render_inline component - expect(page).to have_link count: 1 - expect(page).to have_link "Support", title: "Support this proposal" - expect(page).to have_link "Support Create a monthly transport ticket" + expect(page).to have_button count: 1 + expect(page).to have_button "Support", title: "Support this proposal" + expect(page).to have_button "Support Create a monthly transport ticket" expect(page).not_to have_content "You have already supported this proposal. Share it!" end @@ -31,7 +30,7 @@ describe Proposals::VotesComponent do render_inline component expect(page).to have_content "You have already supported this proposal. Share it!" - expect(page).not_to have_link "Support" + expect(page).not_to have_button "Support", disabled: :all end end diff --git a/spec/system/management/proposals_spec.rb b/spec/system/management/proposals_spec.rb index 660fa6588..421b2a080 100644 --- a/spec/system/management/proposals_spec.rb +++ b/spec/system/management/proposals_spec.rb @@ -149,7 +149,7 @@ describe "Proposals" do click_link "Support proposals" within(".proposals-list") do - click_link("Support") + click_button "Support" expect(page).to have_content "1 support" expect(page).to have_content "You have already supported this proposal. Share it!" end @@ -164,7 +164,7 @@ describe "Proposals" do within(".proposals-list") { click_link proposal.title } expect(page).to have_content proposal.code - within("#proposal_#{proposal.id}_votes") { click_link("Support") } + within("#proposal_#{proposal.id}_votes") { click_button "Support" } expect(page).to have_content "1 support" expect(page).to have_content "You have already supported this proposal. Share it!" @@ -241,7 +241,7 @@ describe "Proposals" do click_link "Print proposals" within ".proposals-list" do - click_link "Support" + click_button "Support" end expect(page).to have_content "To perform this action you must select a user" diff --git a/spec/system/votes_spec.rb b/spec/system/votes_spec.rb index 3dcfcbbb3..b45d7e6eb 100644 --- a/spec/system/votes_spec.rb +++ b/spec/system/votes_spec.rb @@ -193,10 +193,10 @@ describe "Votes" do visit proposal_path(proposal) within(".supports") do - find(".in-favor a").click - expect(page).to have_content "1 support" + click_button "Support" - expect(page).not_to have_selector ".in-favor a" + expect(page).to have_content "1 support" + expect(page).not_to have_button "Support" end end @@ -215,7 +215,7 @@ describe "Votes" do visit proposal_path(proposal) within(".supports") do - find(".in-favor a").click + click_button "Support" expect(page).to have_content "1 support" expect(page).to have_content "You have already supported this proposal. Share it!" @@ -226,7 +226,7 @@ describe "Votes" do visit proposals_path within("#proposal_#{proposal.id}") do - find(".in-favor a").click + click_button "Support" expect(page).to have_content "1 support" expect(page).to have_content "You have already supported this proposal. Share it!" @@ -238,7 +238,7 @@ describe "Votes" do visit proposals_path within("#proposal_#{proposal.id}") do - find(".in-favor a").click + click_button "Support" expect(page).to have_content "You have already supported this proposal. Share it!" end