Replace support proposal link with a button
As mentioned in commits5311daadfandbb958daf0, using links combined with JavaScript to generate POST requests to the server has a few issues.
This commit is contained in:
@@ -6,17 +6,16 @@
|
||||
<div class="supported callout success">
|
||||
<%= t("proposals.proposal.already_supported") %>
|
||||
</div>
|
||||
<% 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 %>
|
||||
<div class="button button-support small expanded">
|
||||
disabled: !can_vote?,
|
||||
"aria-label": support_aria_label do %>
|
||||
<%= t("proposals.proposal.support") %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user