Merge pull request #4776 from consul/vote_accessibility

Make buttons to vote more accessible
This commit is contained in:
Javi Martín
2022-02-23 17:45:29 +01:00
committed by GitHub
31 changed files with 419 additions and 342 deletions

View File

@@ -1,8 +1,18 @@
.in-favor-against { .in-favor-against {
display: inline-block; @include flex-with-gap($line-height / 4);
.icon-like, @include breakpoint(medium) {
.icon-unlike { @include flex-with-gap($line-height * 3 / 4);
}
&,
.in-favor,
.against,
form {
display: inline-block;
}
button {
background: #fff; background: #fff;
border: 2px solid; border: 2px solid;
border-radius: rem-calc(3); border-radius: rem-calc(3);
@@ -10,7 +20,7 @@
display: inline-block; display: inline-block;
font-size: rem-calc(30); font-size: rem-calc(30);
line-height: rem-calc(30); line-height: rem-calc(30);
padding: rem-calc(3) rem-calc(6); padding: rem-calc(3) rem-calc(6) rem-calc(6);
position: relative; position: relative;
&:hover, &:hover,
@@ -21,7 +31,8 @@
} }
} }
.icon-like { .in-favor button {
@include has-fa-icon(thumbs-up, solid);
&:hover, &:hover,
&:active { &:active {
@@ -30,7 +41,8 @@
} }
} }
.icon-unlike { .against button {
@include has-fa-icon(thumbs-down, solid);
&:hover, &:hover,
&:active { &:active {
@@ -41,9 +53,9 @@
.like, .like,
.unlike { .unlike {
line-height: rem-calc(48);
vertical-align: super; vertical-align: super;
text-decoration: none; text-decoration: none;
}
.percentage { .percentage {
color: $text; color: $text;
@@ -59,39 +71,22 @@
padding-right: 0; padding-right: 0;
} }
} }
}
.voted { .voted {
.icon-like,
.icon-unlike {
color: #fff; color: #fff;
} }
.icon-like { .in-favor .voted {
background: $like; background: $like;
border: 2px solid $like; border: 2px solid $like;
} }
.icon-unlike { .against .voted {
background: $unlike; background: $unlike;
border: 2px solid $unlike; border: 2px solid $unlike;
} }
}
.no-voted { .no-voted {
.icon-like,
.icon-unlike {
opacity: 0.3; opacity: 0.3;
} }
} }
.against {
margin-left: $line-height / 4;
}
.divider {
margin: 0 rem-calc(6);
}
}

View File

@@ -1887,7 +1887,7 @@ table {
display: inline-block; display: inline-block;
} }
form { .comment-form form {
margin-top: $line-height / 2; margin-top: $line-height / 2;
} }
} }
@@ -2004,23 +2004,32 @@ table {
.comment-votes { .comment-votes {
a, button,
.icon-like, form {
.icon-unlike {
color: $text-light; color: $text-light;
display: inline-block; display: inline-block;
vertical-align: top;
} }
a:hover { button {
color: $text-medium; font-size: $base-font-size;
text-decoration: none;
.icon-like { &:hover {
cursor: pointer;
}
}
.in-favor button {
@include has-fa-icon(thumbs-up, solid);
&:hover {
color: $like; color: $like;
} }
}
.icon-unlike { .against button {
@include has-fa-icon(thumbs-down, solid);
&:hover {
color: $unlike; color: $unlike;
} }
} }

View File

@@ -746,22 +746,6 @@
content: "|"; content: "|";
} }
} }
.icon-like,
.icon-unlike {
cursor: pointer;
color: #c7c7c7;
&:hover,
&:active,
&:focus {
color: #838383;
}
}
.icon-like {
margin-right: rem-calc(4);
}
} }
} }
} }

View File

@@ -8,13 +8,15 @@
<%= investment.formatted_price %> <%= investment.formatted_price %>
</p> </p>
<% if investment.should_show_ballots? %> <% if investment.should_show_ballots? %>
<%= link_to t("budgets.ballots.show.remove"), <%= button_to budget_ballot_line_path(id: investment.id,
budget_ballot_line_path(id: investment.id,
budget_id: investment.budget_id, budget_id: investment.budget_id,
investments_ids: investment_ids), investments_ids: investment_ids),
class: "button button-remove-support expanded", class: "button button-remove-support expanded",
method: :delete, method: :delete,
remote: true %> remote: true,
"aria-label": remove_vote_aria_label do %>
<%= t("budgets.ballots.show.remove") %>
<% end %>
<% end %> <% end %>
</div> </div>
<% else %> <% else %>
@@ -23,19 +25,23 @@
<%= investment.formatted_price %> <%= investment.formatted_price %>
</p> </p>
<% if investment.should_show_ballots? %> <% if investment.should_show_ballots? %>
<%= link_to t("budgets.investments.investment.add"), <%= button_to budget_ballot_lines_path(investment_id: investment.id,
budget_ballot_lines_path(investment_id: investment.id,
budget_id: investment.budget_id, budget_id: investment.budget_id,
investments_ids: investment_ids), investments_ids: investment_ids),
class: "button button-support expanded", class: "button button-support expanded",
title: t("budgets.investments.investment.support_title"), title: t("budgets.investments.investment.support_title"),
method: :post, method: :post,
remote: true %> remote: true,
disabled: reason.present?,
"aria-label": vote_aria_label do %>
<%= t("budgets.investments.investment.add") %>
<% end %>
<% end %> <% end %>
</div> </div>
<% end %> <% end %>
<% if reason.present? && !voted? %> <% if reason.present? && !voted? %>
<div tabindex="0">
<div class="participation-not-allowed" style="display:none"> <div class="participation-not-allowed" style="display:none">
<p> <p>
<small> <small>
@@ -47,5 +53,6 @@
</small> </small>
</p> </p>
</div> </div>
</div>
<% end %> <% end %>
</div> </div>

View File

@@ -24,6 +24,14 @@ class Budgets::Investments::BallotComponent < ApplicationComponent
@reason ||= investment.reason_for_not_being_ballotable_by(current_user, ballot) @reason ||= investment.reason_for_not_being_ballotable_by(current_user, ballot)
end end
def vote_aria_label
t("budgets.investments.investment.add_label", investment: investment.title)
end
def remove_vote_aria_label
t("budgets.ballots.show.remove_label", investment: investment.title)
end
def link_to_my_heading def link_to_my_heading
link_to(investment.heading.name, link_to(investment.heading.name,
budget_investments_path(budget_id: investment.budget_id, budget_investments_path(budget_id: investment.budget_id,

View File

@@ -2,34 +2,24 @@
<%= t("comments.comment.votes", count: comment.total_votes) %> <%= t("comments.comment.votes", count: comment.total_votes) %>
&nbsp;|&nbsp; &nbsp;|&nbsp;
<span class="in_favor"> <span class="in-favor">
<% if can?(:vote, comment) %> <%= button_to vote_comment_path(comment, value: "yes"),
<%= link_to vote_comment_path(comment, value: "yes"), method: "post",
method: "post", remote: true, title: t("votes.agree") do %> remote: true,
<span class="icon-like"> title: t("votes.agree"),
disabled: !can?(:vote, comment) do %>
<span class="show-for-sr"><%= t("votes.agree") %></span> <span class="show-for-sr"><%= t("votes.agree") %></span>
</span>
<% end %>
<% else %>
<span class="icon-like">
<span class="show-for-sr"><%= t("votes.agree") %></span>
</span>
<% end %> <% end %>
<%= comment.total_likes %> <%= comment.total_likes %>
</span> </span>
<span class="against"> <span class="against">
<% if can?(:vote, comment) %> <%= button_to vote_comment_path(comment, value: "no"),
<%= link_to vote_comment_path(comment, value: "no"), method: "post",
method: "post", remote: true, title: t("votes.disagree") do %> remote: true,
<span class="icon-unlike"> title: t("votes.disagree"),
disabled: !can?(:vote, comment) do %>
<span class="show-for-sr"><%= t("votes.disagree") %></span> <span class="show-for-sr"><%= t("votes.disagree") %></span>
</span>
<% end %>
<% else %>
<span class="icon-unlike">
<span class="show-for-sr"><%= t("votes.disagree") %></span>
</span>
<% end %> <% end %>
<%= comment.total_dislikes %> <%= comment.total_dislikes %>
</span> </span>

View File

@@ -6,16 +6,16 @@
<div class="supported callout success"> <div class="supported callout success">
<%= t("proposals.proposal.already_supported") %> <%= t("proposals.proposal.already_supported") %>
</div> </div>
<% elsif can_vote? %> <% else %>
<%= link_to t("proposals.proposal.support"), vote_url, <%= button_to vote_url,
class: "button button-support small expanded", class: "button button-support small expanded",
title: t("proposals.proposal.support_title"), title: t("proposals.proposal.support_title"),
method: "post", method: "post",
remote: true %> remote: true,
<% else %> disabled: !can_vote?,
<div class="button button-support small expanded"> "aria-label": support_aria_label do %>
<%= t("proposals.proposal.support") %> <%= t("proposals.proposal.support") %>
</div> <% end %>
<% end %> <% end %>
</div> </div>

View File

@@ -21,6 +21,10 @@ class Proposals::VotesComponent < ApplicationComponent
proposal.votable_by?(current_user) proposal.votable_by?(current_user)
end end
def support_aria_label
t("proposals.proposal.support_label", proposal: proposal.title)
end
def organization? def organization?
current_user&.organization? current_user&.organization?
end end

View File

@@ -1,40 +1,27 @@
<div class="in-favor-against"> <div class="in-favor-against">
<div class="in-favor inline-block"> <div class="in-favor">
<% if current_user %> <%= button_to polymorphic_path(votable, action: :vote, value: "yes"),
<%= link_to polymorphic_path(votable, action: :vote, value: "yes"), class: "like #{voted_classes[:in_favor]}",
class: "like #{voted_classes[:in_favor]}", title: t("votes.agree"), method: "post", remote: true do %> title: t("votes.agree"),
<span class="icon-like"> "aria-label": agree_aria_label,
method: "post",
remote: true,
disabled: !current_user do %>
<span class="show-for-sr"><%= t("votes.agree") %></span> <span class="show-for-sr"><%= t("votes.agree") %></span>
</span>
<span class="percentage"><%= votes_percentage("likes", votable) %></span>
<% end %> <% end %>
<% else %>
<div class="like">
<span class="icon-like">
<span class="show-for-sr"><%= t("votes.agree") %></span>
</span>
<span class="percentage"><%= votes_percentage("likes", votable) %></span> <span class="percentage"><%= votes_percentage("likes", votable) %></span>
</div> </div>
<% end %>
</div>
<span class="divider"></span> <div class="against">
<%= button_to polymorphic_path(votable, action: :vote, value: "no"),
<div class="against inline-block"> class: "unlike #{voted_classes[:against]}",
<% if current_user %> title: t("votes.disagree"),
<%= link_to polymorphic_path(votable, action: :vote, value: "no"), class: "unlike #{voted_classes[:against]}", title: t("votes.disagree"), method: "post", remote: true do %> "aria-label": disagree_aria_label,
<span class="icon-unlike"> method: "post",
remote: true,
disabled: !current_user do %>
<span class="show-for-sr"><%= t("votes.disagree") %></span> <span class="show-for-sr"><%= t("votes.disagree") %></span>
</span>
<span class="percentage"><%= votes_percentage("dislikes", votable) %></span>
<% end %> <% end %>
<% else %>
<div class="unlike">
<span class="icon-unlike">
<span class="show-for-sr"><%= t("votes.disagree") %></span>
</span>
<span class="percentage"><%= votes_percentage("dislikes", votable) %></span> <span class="percentage"><%= votes_percentage("dislikes", votable) %></span>
</div> </div>
<% end %>
</div>
</div> </div>

View File

@@ -22,4 +22,12 @@ class Shared::InFavorAgainstComponent < ApplicationComponent
{ in_favor: "", against: "" } { in_favor: "", against: "" }
end end
end end
def agree_aria_label
t("votes.agree_label", title: votable.title)
end
def disagree_aria_label
t("votes.disagree_label", title: votable.title)
end
end end

View File

@@ -23,6 +23,7 @@ en:
other: "You can vote up to <span>%{count}</span> projects" other: "You can vote up to <span>%{count}</span> projects"
no_balloted_group_yet: "You have not voted on this group yet, go vote!" no_balloted_group_yet: "You have not voted on this group yet, go vote!"
remove: Remove vote remove: Remove vote
remove_label: "Remove your vote for %{investment}"
voted: voted:
one: "You have voted <span>one</span> investment." one: "You have voted <span>one</span> investment."
other: "You have voted <span>%{count}</span> investments." other: "You have voted <span>%{count}</span> investments."
@@ -151,6 +152,7 @@ en:
wrong_price_format: Only integer numbers wrong_price_format: Only integer numbers
investment: investment:
add: Vote add: Vote
add_label: "Vote %{investment}"
already_added: You have already added this investment project already_added: You have already added this investment project
support_title: Support this project support_title: Support this project
supports: supports:

View File

@@ -408,6 +408,7 @@ en:
other: "%{count} comments" other: "%{count} comments"
zero: No comments zero: No comments
support: Support support: Support
support_label: "Support %{proposal}"
support_title: Support this proposal support_title: Support this proposal
supports: supports:
one: 1 support one: 1 support
@@ -846,9 +847,11 @@ en:
retired_help_text: Dashboard not available for retired proposals retired_help_text: Dashboard not available for retired proposals
votes: votes:
agree: I agree agree: I agree
agree_label: "I agree with %{title}"
anonymous: Too many anonymous votes to admit vote %{verify_account}. anonymous: Too many anonymous votes to admit vote %{verify_account}.
comment_unauthenticated: You must %{signin} or %{signup} to vote. comment_unauthenticated: You must %{signin} or %{signup} to vote.
disagree: I disagree disagree: I disagree
disagree_label: "I don't agree with %{title}"
organizations: Organizations are not permitted to vote organizations: Organizations are not permitted to vote
supports: Supports supports: Supports
verified_only: Only verified users can vote on proposals; %{verify_account}. verified_only: Only verified users can vote on proposals; %{verify_account}.

View File

@@ -23,6 +23,7 @@ es:
other: "Puedes votar hasta <span>%{count}</span> proyectos" other: "Puedes votar hasta <span>%{count}</span> proyectos"
no_balloted_group_yet: "Todavía no has votado proyectos de este grupo, ¡vota!" no_balloted_group_yet: "Todavía no has votado proyectos de este grupo, ¡vota!"
remove: Quitar voto remove: Quitar voto
remove_label: "Quitar tu voto a %{investment}"
voted: voted:
one: "Has votado <span>un</span> proyecto." one: "Has votado <span>un</span> proyecto."
other: "Has votado <span>%{count}</span> proyectos." other: "Has votado <span>%{count}</span> proyectos."
@@ -151,6 +152,7 @@ es:
wrong_price_format: Solo puede incluir caracteres numéricos wrong_price_format: Solo puede incluir caracteres numéricos
investment: investment:
add: Votar add: Votar
add_label: "Votar %{investment}"
already_added: Ya has añadido este proyecto de gasto already_added: Ya has añadido este proyecto de gasto
support_title: Apoyar este proyecto support_title: Apoyar este proyecto
supports: supports:

View File

@@ -408,6 +408,7 @@ es:
one: 1 Comentario one: 1 Comentario
other: "%{count} Comentarios" other: "%{count} Comentarios"
support: Apoyar support: Apoyar
support_label: "Apoyar %{proposal}"
support_title: Apoyar esta propuesta support_title: Apoyar esta propuesta
supports: supports:
zero: Sin apoyos zero: Sin apoyos
@@ -846,9 +847,11 @@ es:
retired_help_text: Dashboard no disponible para propuestas retiradas retired_help_text: Dashboard no disponible para propuestas retiradas
votes: votes:
agree: Estoy de acuerdo agree: Estoy de acuerdo
agree_label: "Estoy de acuerdo con %{title}"
anonymous: Demasiados votos anónimos, para poder votar %{verify_account}. anonymous: Demasiados votos anónimos, para poder votar %{verify_account}.
comment_unauthenticated: Necesitas %{signin} o %{signup} para poder votar. comment_unauthenticated: Necesitas %{signin} o %{signup} para poder votar.
disagree: No estoy de acuerdo disagree: No estoy de acuerdo
disagree_label: "No estoy de acuerdo con %{title}"
organizations: Las organizaciones no pueden votar. organizations: Las organizaciones no pueden votar.
supports: Apoyos supports: Apoyos
verified_only: Las propuestas sólo pueden ser votadas por usuarios verificados, %{verify_account}. verified_only: Las propuestas sólo pueden ser votadas por usuarios verificados, %{verify_account}.

View File

@@ -0,0 +1,47 @@
require "rails_helper"
describe Budgets::Investments::BallotComponent do
describe "vote investment button" do
let(:budget) { create(:budget, :balloting) }
let(:investment) { create(:budget_investment, :selected, title: "New Sports Center", budget: budget) }
let(:component) do
Budgets::Investments::BallotComponent.new(
investment: investment,
investment_ids: [],
ballot: Budget::Ballot.where(budget: budget, user: controller.current_user).first_or_create!,
assigned_heading: nil
)
end
it "is shown alongside a 'not allowed' message to unverified users" do
sign_in(create(:user))
render_inline component
expect(page).to have_button "Vote", disabled: true
expect(page).to have_content "Only verified users can vote on investments; verify your account."
end
it "is shown to verified users" do
sign_in(create(:user, :level_two))
render_inline component
expect(page).to have_button count: 1
expect(page).to have_button "Vote", title: "Support this project"
expect(page).to have_button "Vote New Sports Center"
expect(page).not_to have_button "Remove vote", disabled: :all
end
it "is replaced with a button to remove the vote when the user has already voted" do
sign_in(create(:user, :level_two, ballot_lines: [investment]))
render_inline component
expect(page).to have_button count: 1
expect(page).to have_button "Remove vote"
expect(page).to have_button "Remove your vote for New Sports Center"
expect(page).not_to have_button "Vote", disabled: :all
end
end
end

View File

@@ -4,15 +4,13 @@ describe Debates::VotesComponent do
let(:debate) { create(:debate, title: "What about the 2030 agenda?") } let(:debate) { create(:debate, title: "What about the 2030 agenda?") }
let(:component) { Debates::VotesComponent.new(debate) } let(:component) { Debates::VotesComponent.new(debate) }
describe "Agree and disagree links" do describe "Agree and disagree buttons" do
it "is shown as plain text to anonymous users" do it "is disabled to anonymous users" do
render_inline component render_inline component
expect(page).to have_content "I agree" expect(page).to have_button "I agree", disabled: true
expect(page).to have_content "I disagree" expect(page).to have_button "I disagree", disabled: true
expect(page).to have_content "You must sign in or sign up to continue." expect(page).to have_content "You must sign in or sign up to continue."
expect(page).not_to have_link "I agree"
expect(page).not_to have_link "I disagree"
end end
it "is shown to identified users" do it "is shown to identified users" do
@@ -20,10 +18,26 @@ describe Debates::VotesComponent do
render_inline component render_inline component
expect(page).to have_link count: 2 expect(page).to have_button count: 2
expect(page).to have_link "I agree", title: "I agree" expect(page).to have_button "I agree", title: "I agree"
expect(page).to have_link "I disagree", title: "I disagree" expect(page).to have_button "I agree with What about the 2030 agenda?"
expect(page).to have_button "I disagree", title: "I disagree"
expect(page).to have_button "I don't agree with What about the 2030 agenda?"
expect(page).not_to have_content "You must sign in or sign up to continue." expect(page).not_to have_content "You must sign in or sign up to continue."
end end
it "does not include result percentages" do
create(:vote, votable: debate)
sign_in(create(:user))
render_inline component
expect(page).to have_button count: 2
expect(page).to have_button "I agree"
expect(page).to have_button "I disagree"
expect(page).not_to have_button text: "%"
expect(page).not_to have_button text: "100"
expect(page).not_to have_button text: "0"
end
end end
end end

View File

@@ -4,7 +4,7 @@ describe Legislation::Proposals::VotesComponent do
let(:proposal) { create(:legislation_proposal, title: "Require wearing masks at home") } let(:proposal) { create(:legislation_proposal, title: "Require wearing masks at home") }
let(:component) { Legislation::Proposals::VotesComponent.new(proposal) } let(:component) { Legislation::Proposals::VotesComponent.new(proposal) }
describe "Agree and disagree links" do describe "Agree and disagree buttons" do
it "is not shown when the proposals phase isn't open" do it "is not shown when the proposals phase isn't open" do
proposal.process.update!( proposal.process.update!(
proposals_phase_start_date: 2.days.ago, proposals_phase_start_date: 2.days.ago,
@@ -14,18 +14,16 @@ describe Legislation::Proposals::VotesComponent do
sign_in(create(:user)) sign_in(create(:user))
render_inline component render_inline component
expect(page).not_to have_content "I agree" expect(page).not_to have_button "I agree", disabled: :all
expect(page).not_to have_content "I disagree" expect(page).not_to have_button "I disagree", disabled: :all
end end
it "is shown as plain text to anonymous users" do it "is disabled to anonymous users" do
render_inline component render_inline component
expect(page).to have_content "I agree" expect(page).to have_button "I agree", disabled: true
expect(page).to have_content "I disagree" expect(page).to have_button "I disagree", disabled: true
expect(page).to have_content "You must sign in or sign up to continue." expect(page).to have_content "You must sign in or sign up to continue."
expect(page).not_to have_link "I agree"
expect(page).not_to have_link "I disagree"
end end
it "is shown to identified users" do it "is shown to identified users" do
@@ -33,10 +31,26 @@ describe Legislation::Proposals::VotesComponent do
render_inline component render_inline component
expect(page).to have_link count: 2 expect(page).to have_button count: 2
expect(page).to have_link "I agree", title: "I agree" expect(page).to have_button "I agree", title: "I agree"
expect(page).to have_link "I disagree", title: "I disagree" expect(page).to have_button "I agree with Require wearing masks at home"
expect(page).to have_button "I disagree", title: "I disagree"
expect(page).to have_button "I don't agree with Require wearing masks at home"
expect(page).not_to have_content "You must sign in or sign up to continue." expect(page).not_to have_content "You must sign in or sign up to continue."
end end
it "does not include result percentages" do
create(:vote, votable: proposal)
sign_in(create(:user))
render_inline component
expect(page).to have_button count: 2
expect(page).to have_button "I agree"
expect(page).to have_button "I disagree"
expect(page).not_to have_button text: "%"
expect(page).not_to have_button text: "100"
expect(page).not_to have_button text: "0"
end
end end
end end

View File

@@ -4,14 +4,13 @@ describe Proposals::VotesComponent do
let(:proposal) { create(:proposal, title: "Create a monthly transport ticket") } let(:proposal) { create(:proposal, title: "Create a monthly transport ticket") }
let(:component) { Proposals::VotesComponent.new(proposal) } let(:component) { Proposals::VotesComponent.new(proposal) }
describe "support proposal link" do describe "support proposal button" do
it "is shown as plain text to unverified users" do it "is disabled to unverified users" do
sign_in(create(:user)) sign_in(create(:user))
render_inline component render_inline component
expect(page).to have_content "Support" expect(page).to have_button "Support", disabled: true
expect(page).not_to have_link "Support"
end end
it "is shown to verified users" do it "is shown to verified users" do
@@ -19,8 +18,9 @@ describe Proposals::VotesComponent do
render_inline component render_inline component
expect(page).to have_link count: 1 expect(page).to have_button count: 1
expect(page).to have_link "Support", title: "Support this proposal" 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!" expect(page).not_to have_content "You have already supported this proposal. Share it!"
end end
@@ -30,7 +30,7 @@ describe Proposals::VotesComponent do
render_inline component render_inline component
expect(page).to have_content "You have already supported this proposal. Share it!" 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
end end

View File

@@ -1,17 +1,17 @@
module Budgets module Budgets
def expect_message_organizations_cannot_vote def expect_message_organizations_cannot_vote
expect(page).to have_content "Organization" expect(page).to have_content "Organization"
expect(page).to have_selector(".in-favor a", obscured: true) expect(page).to have_button "Vote", disabled: true, obscured: true
end end
def hover_over_ballot def hover_over_ballot
scroll_to find("div.ballot"), align: :bottom scroll_to find("div.ballot"), align: :bottom
find("div.ballot").hover first("div.ballot p").hover
end end
def add_to_ballot(investment_title) def add_to_ballot(investment_title)
within(".budget-investment", text: investment_title) do within(".budget-investment", text: investment_title) do
find(".add a").click click_button "Vote"
expect(page).to have_content "Remove" expect(page).to have_content "Remove"
end end
end end

View File

@@ -12,7 +12,7 @@ module Votes
def expect_message_to_many_anonymous_votes def expect_message_to_many_anonymous_votes
expect(page).to have_content "Too many anonymous votes to admit vote" expect(page).to have_content "Too many anonymous votes to admit vote"
expect(page).to have_selector(".in-favor a", obscured: true) expect(page).to have_button "I agree", obscured: true
end end
def expect_message_only_verified_can_vote_proposals def expect_message_only_verified_can_vote_proposals

View File

@@ -81,11 +81,11 @@ describe "BudgetPolls", :with_frozen_time do
login_as(user) login_as(user)
visit budget_investment_path(budget, investment) visit budget_investment_path(budget, investment)
find("div.ballot").hover first("div.ballot p").hover
within("#budget_investment_#{investment.id}") do within("#budget_investment_#{investment.id}") do
expect(page).to have_content "You have already participated offline" expect(page).to have_content "You have already participated offline"
expect(page).to have_css(".add a", obscured: true) expect(page).to have_button "Vote", disabled: true, obscured: true
end end
end end
end end
@@ -96,7 +96,7 @@ describe "BudgetPolls", :with_frozen_time do
visit budget_investment_path(budget, investment) visit budget_investment_path(budget, investment)
within("#budget_investment_#{investment.id}") do within("#budget_investment_#{investment.id}") do
find(".add a").click click_button "Vote"
expect(page).to have_content "Remove" expect(page).to have_content "Remove"
end end
end end
@@ -106,7 +106,7 @@ describe "BudgetPolls", :with_frozen_time do
visit budget_investment_path(budget, investment) visit budget_investment_path(budget, investment)
within("#budget_investment_#{investment.id}") do within("#budget_investment_#{investment.id}") do
find(".add a").click click_button "Vote"
expect(page).to have_content "Remove" expect(page).to have_content "Remove"
end end
@@ -123,7 +123,7 @@ describe "BudgetPolls", :with_frozen_time do
visit budget_investment_path(budget, investment) visit budget_investment_path(budget, investment)
within("#budget_investment_#{investment.id}") do within("#budget_investment_#{investment.id}") do
find(".add a").click click_button "Vote"
expect(page).to have_content "Remove" expect(page).to have_content "Remove"
end end

View File

@@ -147,7 +147,7 @@ describe "Ballots" do
end end
within("#budget_investment_#{investment.id}") do within("#budget_investment_#{investment.id}") do
find(".remove a").click click_button "Remove vote"
end end
expect(page).to have_css("#total_amount", text: "€0") expect(page).to have_css("#total_amount", text: "€0")
@@ -177,7 +177,7 @@ describe "Ballots" do
end end
within(".budget-investment", text: "More bridges") do within(".budget-investment", text: "More bridges") do
click_link "Remove vote" click_button "Remove vote"
end end
within("#sidebar") do within("#sidebar") do
@@ -283,8 +283,8 @@ describe "Ballots" do
visit budget_investments_path(budget, heading_id: california.id) visit budget_investments_path(budget, heading_id: california.id)
within(".budget-investment", text: "Early ShakeAlert") do within(".budget-investment", text: "Early ShakeAlert") do
find(".remove a").click click_button "Remove vote"
expect(page).to have_link "Vote" expect(page).to have_button "Vote"
end end
visit budget_investments_path(budget, heading_id: new_york.id) visit budget_investments_path(budget, heading_id: new_york.id)
@@ -449,7 +449,7 @@ describe "Ballots" do
hover_over_ballot hover_over_ballot
expect(page).to have_content "You must sign in or sign up to continue." expect(page).to have_content "You must sign in or sign up to continue."
expect(page).to have_selector(".in-favor a", obscured: true) expect(page).to have_button "Vote", disabled: true, obscured: true
end end
end end
@@ -464,7 +464,7 @@ describe "Ballots" do
hover_over_ballot hover_over_ballot
expect(page).to have_content "Only verified users can vote on investments" expect(page).to have_content "Only verified users can vote on investments"
expect(page).to have_selector(".in-favor a", obscured: true) expect(page).to have_button "Vote", disabled: true, obscured: true
end end
end end
@@ -515,7 +515,7 @@ describe "Ballots" do
hover_over_ballot hover_over_ballot
expect(page).to have_content("already voted a different heading") expect(page).to have_content("already voted a different heading")
expect(page).to have_selector(".in-favor a", obscured: true) expect(page).to have_button "Vote", disabled: true, obscured: true
end end
end end
@@ -531,7 +531,7 @@ describe "Ballots" do
hover_over_ballot hover_over_ballot
expect(page).to have_content("You have already assigned the available budget") expect(page).to have_content("You have already assigned the available budget")
expect(page).to have_selector(".in-favor a", obscured: true) expect(page).to have_button "Vote", disabled: true, obscured: true
end end
end end
@@ -546,7 +546,7 @@ describe "Ballots" do
hover_over_ballot hover_over_ballot
expect(page).not_to have_content("You have already assigned the available budget") expect(page).not_to have_content("You have already assigned the available budget")
expect(page).to have_selector(".in-favor a", obscured: false) expect(page).to have_button "Vote", obscured: false
end end
add_to_ballot("Build replicants") add_to_ballot("Build replicants")
@@ -555,7 +555,7 @@ describe "Ballots" do
hover_over_ballot hover_over_ballot
expect(page).to have_content("You have already assigned the available budget") expect(page).to have_content("You have already assigned the available budget")
expect(page).to have_selector(".in-favor a", obscured: true) expect(page).to have_button "Vote", disabled: true, obscured: true
end end
end end
@@ -571,19 +571,19 @@ describe "Ballots" do
hover_over_ballot hover_over_ballot
expect(page).to have_content("You have already assigned the available budget") expect(page).to have_content("You have already assigned the available budget")
expect(page).to have_selector(".in-favor a", obscured: true) expect(page).to have_button "Vote", disabled: true, obscured: true
end end
within("#budget_investment_#{bi1.id}") do within("#budget_investment_#{bi1.id}") do
find(".remove a").click click_button "Remove vote"
expect(page).to have_css ".add a" expect(page).to have_button "Vote"
end end
within("#budget_investment_#{bi2.id}") do within("#budget_investment_#{bi2.id}") do
hover_over_ballot hover_over_ballot
expect(page).not_to have_content("You have already assigned the available budget") expect(page).not_to have_content("You have already assigned the available budget")
expect(page).to have_selector(".in-favor a", obscured: false) expect(page).to have_button "Vote", obscured: false
end end
end end
@@ -599,7 +599,7 @@ describe "Ballots" do
hover_over_ballot hover_over_ballot
expect(page).to have_content("You have already assigned the available budget") expect(page).to have_content("You have already assigned the available budget")
expect(page).to have_selector(".in-favor a", obscured: true) expect(page).to have_button "Vote", disabled: true, obscured: true
end end
within("#budget_investment_#{bi1.id}_sidebar") do within("#budget_investment_#{bi1.id}_sidebar") do
@@ -612,7 +612,7 @@ describe "Ballots" do
hover_over_ballot hover_over_ballot
expect(page).not_to have_content("You have already assigned the available budget") expect(page).not_to have_content("You have already assigned the available budget")
expect(page).to have_selector(".in-favor a", obscured: false) expect(page).to have_button "Vote", obscured: false
end end
end end
@@ -623,7 +623,7 @@ describe "Ballots" do
login_as user login_as user
visit budget_investments_path(budget, heading_id: new_york) visit budget_investments_path(budget, heading_id: new_york)
expect(page).to have_css(".in-favor a") expect(page).to have_button "Vote"
in_browser(:admin) do in_browser(:admin) do
login_as admin_user login_as admin_user
@@ -639,7 +639,7 @@ describe "Ballots" do
end end
within("#budget_investment_#{investment1.id}") do within("#budget_investment_#{investment1.id}") do
find(".in-favor a").click click_button "Vote"
expect(page).not_to have_content "Remove" expect(page).not_to have_content "Remove"
expect(page).not_to have_selector(".participation-not-allowed") expect(page).not_to have_selector(".participation-not-allowed")
@@ -647,7 +647,7 @@ describe "Ballots" do
hover_over_ballot hover_over_ballot
expect(page).to have_selector(".participation-not-allowed") expect(page).to have_selector(".participation-not-allowed")
expect(page).to have_selector(".in-favor a", obscured: true) expect(page).to have_button "Vote", disabled: true, obscured: true
end end
end end

View File

@@ -509,7 +509,7 @@ describe "Commenting Budget::Investments" do
visit budget_investment_path(budget, investment) visit budget_investment_path(budget, investment)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
@@ -525,9 +525,9 @@ describe "Commenting Budget::Investments" do
visit budget_investment_path(budget, investment) visit budget_investment_path(budget, investment)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
@@ -543,15 +543,15 @@ describe "Commenting Budget::Investments" do
visit budget_investment_path(budget, investment) visit budget_investment_path(budget, investment)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
find(".against a").click click_button "I disagree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "0" expect(page).to have_content "0"
end end
@@ -567,15 +567,15 @@ describe "Commenting Budget::Investments" do
visit budget_investment_path(budget, investment) visit budget_investment_path(budget, investment)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end

View File

@@ -331,7 +331,7 @@ describe "Commenting debates" do
fill_in "Leave your comment", with: "Probably if government approves." fill_in "Leave your comment", with: "Probably if government approves."
click_button "Publish reply" click_button "Publish reply"
expect(page).not_to have_selector("form") expect(page).not_to have_css ".comment-form"
within ".comment" do within ".comment" do
expect(page).to have_content "Probably if government approves." expect(page).to have_content "Probably if government approves."
@@ -558,7 +558,7 @@ describe "Commenting debates" do
visit debate_path(debate) visit debate_path(debate)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
@@ -574,9 +574,9 @@ describe "Commenting debates" do
visit debate_path(debate) visit debate_path(debate)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
@@ -592,15 +592,15 @@ describe "Commenting debates" do
visit debate_path(debate) visit debate_path(debate)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
find(".against a").click click_button "I disagree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "0" expect(page).to have_content "0"
end end
@@ -616,13 +616,13 @@ describe "Commenting debates" do
visit debate_path(debate) visit debate_path(debate)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).not_to have_content "2" expect(page).not_to have_content "2"
expect(page).to have_content "1" expect(page).to have_content "1"
end end

View File

@@ -523,7 +523,7 @@ describe "Commenting legislation questions" do
annotation) annotation)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
@@ -541,9 +541,9 @@ describe "Commenting legislation questions" do
annotation) annotation)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
@@ -561,15 +561,15 @@ describe "Commenting legislation questions" do
annotation) annotation)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
find(".against a").click click_button "I disagree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "0" expect(page).to have_content "0"
end end
@@ -587,13 +587,13 @@ describe "Commenting legislation questions" do
annotation) annotation)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).not_to have_content "2" expect(page).not_to have_content "2"
expect(page).to have_content "1" expect(page).to have_content "1"
end end

View File

@@ -475,7 +475,7 @@ describe "Commenting legislation questions" do
visit legislation_process_question_path(question.process, question) visit legislation_process_question_path(question.process, question)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
@@ -491,9 +491,9 @@ describe "Commenting legislation questions" do
visit legislation_process_question_path(question.process, question) visit legislation_process_question_path(question.process, question)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
@@ -509,15 +509,15 @@ describe "Commenting legislation questions" do
visit legislation_process_question_path(question.process, question) visit legislation_process_question_path(question.process, question)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
find(".against a").click click_button "I disagree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "0" expect(page).to have_content "0"
end end
@@ -533,13 +533,13 @@ describe "Commenting legislation questions" do
visit legislation_process_question_path(question.process, question) visit legislation_process_question_path(question.process, question)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).not_to have_content "2" expect(page).not_to have_content "2"
expect(page).to have_content "1" expect(page).to have_content "1"
end end

View File

@@ -453,7 +453,7 @@ describe "Commenting polls" do
visit poll_path(poll) visit poll_path(poll)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
@@ -469,9 +469,9 @@ describe "Commenting polls" do
visit poll_path(poll) visit poll_path(poll)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
@@ -487,15 +487,15 @@ describe "Commenting polls" do
visit poll_path(poll) visit poll_path(poll)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
find(".against a").click click_button "I disagree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "0" expect(page).to have_content "0"
end end
@@ -511,15 +511,15 @@ describe "Commenting polls" do
visit poll_path(poll) visit poll_path(poll)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end

View File

@@ -441,7 +441,7 @@ describe "Commenting proposals" do
visit proposal_path(proposal) visit proposal_path(proposal)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
@@ -457,9 +457,9 @@ describe "Commenting proposals" do
visit proposal_path(proposal) visit proposal_path(proposal)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
@@ -475,15 +475,15 @@ describe "Commenting proposals" do
visit proposal_path(proposal) visit proposal_path(proposal)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
find(".against a").click click_button "I disagree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "0" expect(page).to have_content "0"
end end
@@ -499,15 +499,15 @@ describe "Commenting proposals" do
visit proposal_path(proposal) visit proposal_path(proposal)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end

View File

@@ -491,7 +491,7 @@ describe "Commenting topics from proposals" do
visit community_topic_path(proposal.community, topic) visit community_topic_path(proposal.community, topic)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
@@ -507,9 +507,9 @@ describe "Commenting topics from proposals" do
visit community_topic_path(proposal.community, topic) visit community_topic_path(proposal.community, topic)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
@@ -525,15 +525,15 @@ describe "Commenting topics from proposals" do
visit community_topic_path(proposal.community, topic) visit community_topic_path(proposal.community, topic)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
find(".against a").click click_button "I disagree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "0" expect(page).to have_content "0"
end end
@@ -549,15 +549,15 @@ describe "Commenting topics from proposals" do
visit community_topic_path(proposal.community, topic) visit community_topic_path(proposal.community, topic)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
@@ -1002,7 +1002,7 @@ describe "Commenting topics from budget investments" do
visit community_topic_path(investment.community, topic) visit community_topic_path(investment.community, topic)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
@@ -1018,9 +1018,9 @@ describe "Commenting topics from budget investments" do
visit community_topic_path(investment.community, topic) visit community_topic_path(investment.community, topic)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
@@ -1036,15 +1036,15 @@ describe "Commenting topics from budget investments" do
visit community_topic_path(investment.community, topic) visit community_topic_path(investment.community, topic)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
find(".against a").click click_button "I disagree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "0" expect(page).to have_content "0"
end end
@@ -1060,15 +1060,15 @@ describe "Commenting topics from budget investments" do
visit community_topic_path(investment.community, topic) visit community_topic_path(investment.community, topic)
within("#comment_#{comment.id}_votes") do within("#comment_#{comment.id}_votes") do
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end
find(".in_favor a").click click_button "I agree"
within(".in_favor") do within(".in-favor") do
expect(page).to have_content "1" expect(page).to have_content "1"
end end

View File

@@ -149,7 +149,7 @@ describe "Proposals" do
click_link "Support proposals" click_link "Support proposals"
within(".proposals-list") do within(".proposals-list") do
click_link("Support") click_button "Support"
expect(page).to have_content "1 support" expect(page).to have_content "1 support"
expect(page).to have_content "You have already supported this proposal. Share it!" expect(page).to have_content "You have already supported this proposal. Share it!"
end end
@@ -164,7 +164,7 @@ describe "Proposals" do
within(".proposals-list") { click_link proposal.title } within(".proposals-list") { click_link proposal.title }
expect(page).to have_content proposal.code 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 "1 support"
expect(page).to have_content "You have already supported this proposal. Share it!" expect(page).to have_content "You have already supported this proposal. Share it!"
@@ -241,7 +241,7 @@ describe "Proposals" do
click_link "Print proposals" click_link "Print proposals"
within ".proposals-list" do within ".proposals-list" do
click_link "Support" click_button "Support"
end end
expect(page).to have_content "To perform this action you must select a user" expect(page).to have_content "To perform this action you must select a user"

View File

@@ -19,37 +19,37 @@ describe "Votes" do
within("#debates") do within("#debates") do
within("#debate_#{debate1.id}_votes") do within("#debate_#{debate1.id}_votes") do
within(".in-favor") do within(".in-favor") do
expect(page).to have_css("a.voted") expect(page).to have_css("button.voted")
expect(page).not_to have_css("a.no-voted") expect(page).not_to have_css("button.no-voted")
end end
within(".against") do within(".against") do
expect(page).to have_css("a.no-voted") expect(page).to have_css("button.no-voted")
expect(page).not_to have_css("a.voted") expect(page).not_to have_css("button.voted")
end end
end end
within("#debate_#{debate2.id}_votes") do within("#debate_#{debate2.id}_votes") do
within(".in-favor") do within(".in-favor") do
expect(page).not_to have_css("a.voted") expect(page).not_to have_css("button.voted")
expect(page).not_to have_css("a.no-voted") expect(page).not_to have_css("button.no-voted")
end end
within(".against") do within(".against") do
expect(page).not_to have_css("a.no-voted") expect(page).not_to have_css("button.no-voted")
expect(page).not_to have_css("a.voted") expect(page).not_to have_css("button.voted")
end end
end end
within("#debate_#{debate3.id}_votes") do within("#debate_#{debate3.id}_votes") do
within(".in-favor") do within(".in-favor") do
expect(page).to have_css("a.no-voted") expect(page).to have_css("button.no-voted")
expect(page).not_to have_css("a.voted") expect(page).not_to have_css("button.voted")
end end
within(".against") do within(".against") do
expect(page).to have_css("a.voted") expect(page).to have_css("button.voted")
expect(page).not_to have_css("a.no-voted") expect(page).not_to have_css("button.no-voted")
end end
end end
end end
@@ -63,37 +63,37 @@ describe "Votes" do
within(".in-favor") do within(".in-favor") do
expect(page).to have_content "0%" expect(page).to have_content "0%"
expect(page).not_to have_css("a.voted") expect(page).not_to have_css("button.voted")
expect(page).not_to have_css("a.no-voted") expect(page).not_to have_css("button.no-voted")
end end
within(".against") do within(".against") do
expect(page).to have_content "0%" expect(page).to have_content "0%"
expect(page).not_to have_css("a.voted") expect(page).not_to have_css("button.voted")
expect(page).not_to have_css("a.no-voted") expect(page).not_to have_css("button.no-voted")
end end
end end
scenario "Update" do scenario "Update" do
visit debate_path(create(:debate)) visit debate_path(create(:debate))
find(".in-favor a").click click_button "I agree"
within(".in-favor") do within(".in-favor") do
expect(page).to have_content "100%" expect(page).to have_content "100%"
expect(page).to have_css("a.voted") expect(page).to have_css("button.voted")
end end
find(".against a").click click_button "I disagree"
within(".in-favor") do within(".in-favor") do
expect(page).to have_content "0%" expect(page).to have_content "0%"
expect(page).to have_css("a.no-voted") expect(page).to have_css("button.no-voted")
end end
within(".against") do within(".against") do
expect(page).to have_content "100%" expect(page).to have_content "100%"
expect(page).to have_css("a.voted") expect(page).to have_css("button.voted")
end end
expect(page).to have_content "1 vote" expect(page).to have_content "1 vote"
@@ -102,9 +102,9 @@ describe "Votes" do
scenario "Trying to vote multiple times" do scenario "Trying to vote multiple times" do
visit debate_path(create(:debate)) visit debate_path(create(:debate))
find(".in-favor a").click click_button "I agree"
expect(page).to have_content "1 vote" expect(page).to have_content "1 vote"
find(".in-favor a").click click_button "I agree"
expect(page).not_to have_content "2 votes" expect(page).not_to have_content "2 votes"
within(".in-favor") do within(".in-favor") do
@@ -127,28 +127,28 @@ describe "Votes" do
within(".in-favor") do within(".in-favor") do
expect(page).to have_content "50%" expect(page).to have_content "50%"
expect(page).to have_css("a.voted") expect(page).to have_css("button.voted")
end end
within(".against") do within(".against") do
expect(page).to have_content "50%" expect(page).to have_content "50%"
expect(page).to have_css("a.no-voted") expect(page).to have_css("button.no-voted")
end end
end end
scenario "Create from debate show" do scenario "Create from debate show" do
visit debate_path(create(:debate)) visit debate_path(create(:debate))
find(".in-favor a").click click_button "I agree"
within(".in-favor") do within(".in-favor") do
expect(page).to have_content "100%" expect(page).to have_content "100%"
expect(page).to have_css("a.voted") expect(page).to have_css("button.voted")
end end
within(".against") do within(".against") do
expect(page).to have_content "0%" expect(page).to have_content "0%"
expect(page).to have_css("a.no-voted") expect(page).to have_css("button.no-voted")
end end
expect(page).to have_content "1 vote" expect(page).to have_content "1 vote"
@@ -159,16 +159,16 @@ describe "Votes" do
visit debates_path visit debates_path
within("#debates") do within("#debates") do
find(".in-favor a").click click_button "I agree"
within(".in-favor") do within(".in-favor") do
expect(page).to have_content "100%" expect(page).to have_content "100%"
expect(page).to have_css("a.voted") expect(page).to have_css("button.voted")
end end
within(".against") do within(".against") do
expect(page).to have_content "0%" expect(page).to have_content "0%"
expect(page).to have_css("a.no-voted") expect(page).to have_css("button.no-voted")
end end
expect(page).to have_content "1 vote" expect(page).to have_content "1 vote"
@@ -193,10 +193,10 @@ describe "Votes" do
visit proposal_path(proposal) visit proposal_path(proposal)
within(".supports") do within(".supports") do
find(".in-favor a").click click_button "Support"
expect(page).to have_content "1 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
end end
@@ -215,7 +215,7 @@ describe "Votes" do
visit proposal_path(proposal) visit proposal_path(proposal)
within(".supports") do within(".supports") do
find(".in-favor a").click click_button "Support"
expect(page).to have_content "1 support" expect(page).to have_content "1 support"
expect(page).to have_content "You have already supported this proposal. Share it!" expect(page).to have_content "You have already supported this proposal. Share it!"
@@ -226,7 +226,7 @@ describe "Votes" do
visit proposals_path visit proposals_path
within("#proposal_#{proposal.id}") do 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 "1 support"
expect(page).to have_content "You have already supported this proposal. Share it!" expect(page).to have_content "You have already supported this proposal. Share it!"
@@ -238,7 +238,7 @@ describe "Votes" do
visit proposals_path visit proposals_path
within("#proposal_#{proposal.id}") do 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!" expect(page).to have_content "You have already supported this proposal. Share it!"
end end