Merge pull request #4776 from consul/vote_accessibility
Make buttons to vote more accessible
This commit is contained in:
@@ -1,8 +1,18 @@
|
||||
.in-favor-against {
|
||||
display: inline-block;
|
||||
@include flex-with-gap($line-height / 4);
|
||||
|
||||
.icon-like,
|
||||
.icon-unlike {
|
||||
@include breakpoint(medium) {
|
||||
@include flex-with-gap($line-height * 3 / 4);
|
||||
}
|
||||
|
||||
&,
|
||||
.in-favor,
|
||||
.against,
|
||||
form {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
button {
|
||||
background: #fff;
|
||||
border: 2px solid;
|
||||
border-radius: rem-calc(3);
|
||||
@@ -10,7 +20,7 @@
|
||||
display: inline-block;
|
||||
font-size: 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;
|
||||
|
||||
&:hover,
|
||||
@@ -21,7 +31,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
.icon-like {
|
||||
.in-favor button {
|
||||
@include has-fa-icon(thumbs-up, solid);
|
||||
|
||||
&:hover,
|
||||
&:active {
|
||||
@@ -30,7 +41,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
.icon-unlike {
|
||||
.against button {
|
||||
@include has-fa-icon(thumbs-down, solid);
|
||||
|
||||
&:hover,
|
||||
&:active {
|
||||
@@ -41,9 +53,9 @@
|
||||
|
||||
.like,
|
||||
.unlike {
|
||||
line-height: rem-calc(48);
|
||||
vertical-align: super;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.percentage {
|
||||
color: $text;
|
||||
@@ -59,39 +71,22 @@
|
||||
padding-right: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.voted {
|
||||
|
||||
.icon-like,
|
||||
.icon-unlike {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.icon-like {
|
||||
.in-favor .voted {
|
||||
background: $like;
|
||||
border: 2px solid $like;
|
||||
}
|
||||
|
||||
.icon-unlike {
|
||||
.against .voted {
|
||||
background: $unlike;
|
||||
border: 2px solid $unlike;
|
||||
}
|
||||
}
|
||||
|
||||
.no-voted {
|
||||
|
||||
.icon-like,
|
||||
.icon-unlike {
|
||||
opacity: 0.3;
|
||||
}
|
||||
}
|
||||
|
||||
.against {
|
||||
margin-left: $line-height / 4;
|
||||
}
|
||||
|
||||
.divider {
|
||||
margin: 0 rem-calc(6);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1887,7 +1887,7 @@ table {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
form {
|
||||
.comment-form form {
|
||||
margin-top: $line-height / 2;
|
||||
}
|
||||
}
|
||||
@@ -2004,23 +2004,32 @@ table {
|
||||
|
||||
.comment-votes {
|
||||
|
||||
a,
|
||||
.icon-like,
|
||||
.icon-unlike {
|
||||
button,
|
||||
form {
|
||||
color: $text-light;
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: $text-medium;
|
||||
text-decoration: none;
|
||||
button {
|
||||
font-size: $base-font-size;
|
||||
|
||||
.icon-like {
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.in-favor button {
|
||||
@include has-fa-icon(thumbs-up, solid);
|
||||
|
||||
&:hover {
|
||||
color: $like;
|
||||
}
|
||||
}
|
||||
|
||||
.icon-unlike {
|
||||
.against button {
|
||||
@include has-fa-icon(thumbs-down, solid);
|
||||
|
||||
&:hover {
|
||||
color: $unlike;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -746,22 +746,6 @@
|
||||
content: "|";
|
||||
}
|
||||
}
|
||||
|
||||
.icon-like,
|
||||
.icon-unlike {
|
||||
cursor: pointer;
|
||||
color: #c7c7c7;
|
||||
|
||||
&:hover,
|
||||
&:active,
|
||||
&:focus {
|
||||
color: #838383;
|
||||
}
|
||||
}
|
||||
|
||||
.icon-like {
|
||||
margin-right: rem-calc(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,13 +8,15 @@
|
||||
<%= investment.formatted_price %>
|
||||
</p>
|
||||
<% if investment.should_show_ballots? %>
|
||||
<%= link_to t("budgets.ballots.show.remove"),
|
||||
budget_ballot_line_path(id: investment.id,
|
||||
<%= button_to budget_ballot_line_path(id: investment.id,
|
||||
budget_id: investment.budget_id,
|
||||
investments_ids: investment_ids),
|
||||
class: "button button-remove-support expanded",
|
||||
method: :delete,
|
||||
remote: true %>
|
||||
remote: true,
|
||||
"aria-label": remove_vote_aria_label do %>
|
||||
<%= t("budgets.ballots.show.remove") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
@@ -23,19 +25,23 @@
|
||||
<%= investment.formatted_price %>
|
||||
</p>
|
||||
<% if investment.should_show_ballots? %>
|
||||
<%= link_to t("budgets.investments.investment.add"),
|
||||
budget_ballot_lines_path(investment_id: investment.id,
|
||||
<%= button_to budget_ballot_lines_path(investment_id: investment.id,
|
||||
budget_id: investment.budget_id,
|
||||
investments_ids: investment_ids),
|
||||
class: "button button-support expanded",
|
||||
title: t("budgets.investments.investment.support_title"),
|
||||
method: :post,
|
||||
remote: true %>
|
||||
remote: true,
|
||||
disabled: reason.present?,
|
||||
"aria-label": vote_aria_label do %>
|
||||
<%= t("budgets.investments.investment.add") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if reason.present? && !voted? %>
|
||||
<div tabindex="0">
|
||||
<div class="participation-not-allowed" style="display:none">
|
||||
<p>
|
||||
<small>
|
||||
@@ -47,5 +53,6 @@
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -24,6 +24,14 @@ class Budgets::Investments::BallotComponent < ApplicationComponent
|
||||
@reason ||= investment.reason_for_not_being_ballotable_by(current_user, ballot)
|
||||
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
|
||||
link_to(investment.heading.name,
|
||||
budget_investments_path(budget_id: investment.budget_id,
|
||||
|
||||
@@ -2,34 +2,24 @@
|
||||
<%= t("comments.comment.votes", count: comment.total_votes) %>
|
||||
|
|
||||
|
||||
<span class="in_favor">
|
||||
<% if can?(:vote, comment) %>
|
||||
<%= link_to vote_comment_path(comment, value: "yes"),
|
||||
method: "post", remote: true, title: t("votes.agree") do %>
|
||||
<span class="icon-like">
|
||||
<span class="in-favor">
|
||||
<%= button_to vote_comment_path(comment, value: "yes"),
|
||||
method: "post",
|
||||
remote: true,
|
||||
title: t("votes.agree"),
|
||||
disabled: !can?(:vote, comment) do %>
|
||||
<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 %>
|
||||
<%= comment.total_likes %>
|
||||
</span>
|
||||
|
||||
<span class="against">
|
||||
<% if can?(:vote, comment) %>
|
||||
<%= link_to vote_comment_path(comment, value: "no"),
|
||||
method: "post", remote: true, title: t("votes.disagree") do %>
|
||||
<span class="icon-unlike">
|
||||
<%= button_to vote_comment_path(comment, value: "no"),
|
||||
method: "post",
|
||||
remote: true,
|
||||
title: t("votes.disagree"),
|
||||
disabled: !can?(:vote, comment) do %>
|
||||
<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 %>
|
||||
<%= comment.total_dislikes %>
|
||||
</span>
|
||||
|
||||
@@ -6,16 +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 %>
|
||||
<% else %>
|
||||
<div class="button button-support small expanded">
|
||||
remote: true,
|
||||
disabled: !can_vote?,
|
||||
"aria-label": support_aria_label do %>
|
||||
<%= t("proposals.proposal.support") %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@ class Proposals::VotesComponent < ApplicationComponent
|
||||
proposal.votable_by?(current_user)
|
||||
end
|
||||
|
||||
def support_aria_label
|
||||
t("proposals.proposal.support_label", proposal: proposal.title)
|
||||
end
|
||||
|
||||
def organization?
|
||||
current_user&.organization?
|
||||
end
|
||||
|
||||
@@ -1,40 +1,27 @@
|
||||
<div class="in-favor-against">
|
||||
<div class="in-favor inline-block">
|
||||
<% if current_user %>
|
||||
<%= link_to polymorphic_path(votable, action: :vote, value: "yes"),
|
||||
class: "like #{voted_classes[:in_favor]}", title: t("votes.agree"), method: "post", remote: true do %>
|
||||
<span class="icon-like">
|
||||
<div class="in-favor">
|
||||
<%= button_to polymorphic_path(votable, action: :vote, value: "yes"),
|
||||
class: "like #{voted_classes[:in_favor]}",
|
||||
title: t("votes.agree"),
|
||||
"aria-label": agree_aria_label,
|
||||
method: "post",
|
||||
remote: true,
|
||||
disabled: !current_user do %>
|
||||
<span class="show-for-sr"><%= t("votes.agree") %></span>
|
||||
</span>
|
||||
<span class="percentage"><%= votes_percentage("likes", votable) %></span>
|
||||
<% 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>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<span class="divider"></span>
|
||||
|
||||
<div class="against inline-block">
|
||||
<% if current_user %>
|
||||
<%= link_to polymorphic_path(votable, action: :vote, value: "no"), class: "unlike #{voted_classes[:against]}", title: t("votes.disagree"), method: "post", remote: true do %>
|
||||
<span class="icon-unlike">
|
||||
<div class="against">
|
||||
<%= button_to polymorphic_path(votable, action: :vote, value: "no"),
|
||||
class: "unlike #{voted_classes[:against]}",
|
||||
title: t("votes.disagree"),
|
||||
"aria-label": disagree_aria_label,
|
||||
method: "post",
|
||||
remote: true,
|
||||
disabled: !current_user do %>
|
||||
<span class="show-for-sr"><%= t("votes.disagree") %></span>
|
||||
</span>
|
||||
<span class="percentage"><%= votes_percentage("dislikes", votable) %></span>
|
||||
<% 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>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -22,4 +22,12 @@ class Shared::InFavorAgainstComponent < ApplicationComponent
|
||||
{ in_favor: "", against: "" }
|
||||
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
|
||||
|
||||
@@ -23,6 +23,7 @@ en:
|
||||
other: "You can vote up to <span>%{count}</span> projects"
|
||||
no_balloted_group_yet: "You have not voted on this group yet, go vote!"
|
||||
remove: Remove vote
|
||||
remove_label: "Remove your vote for %{investment}"
|
||||
voted:
|
||||
one: "You have voted <span>one</span> investment."
|
||||
other: "You have voted <span>%{count}</span> investments."
|
||||
@@ -151,6 +152,7 @@ en:
|
||||
wrong_price_format: Only integer numbers
|
||||
investment:
|
||||
add: Vote
|
||||
add_label: "Vote %{investment}"
|
||||
already_added: You have already added this investment project
|
||||
support_title: Support this project
|
||||
supports:
|
||||
|
||||
@@ -408,6 +408,7 @@ en:
|
||||
other: "%{count} comments"
|
||||
zero: No comments
|
||||
support: Support
|
||||
support_label: "Support %{proposal}"
|
||||
support_title: Support this proposal
|
||||
supports:
|
||||
one: 1 support
|
||||
@@ -846,9 +847,11 @@ en:
|
||||
retired_help_text: Dashboard not available for retired proposals
|
||||
votes:
|
||||
agree: I agree
|
||||
agree_label: "I agree with %{title}"
|
||||
anonymous: Too many anonymous votes to admit vote %{verify_account}.
|
||||
comment_unauthenticated: You must %{signin} or %{signup} to vote.
|
||||
disagree: I disagree
|
||||
disagree_label: "I don't agree with %{title}"
|
||||
organizations: Organizations are not permitted to vote
|
||||
supports: Supports
|
||||
verified_only: Only verified users can vote on proposals; %{verify_account}.
|
||||
|
||||
@@ -23,6 +23,7 @@ es:
|
||||
other: "Puedes votar hasta <span>%{count}</span> proyectos"
|
||||
no_balloted_group_yet: "Todavía no has votado proyectos de este grupo, ¡vota!"
|
||||
remove: Quitar voto
|
||||
remove_label: "Quitar tu voto a %{investment}"
|
||||
voted:
|
||||
one: "Has votado <span>un</span> proyecto."
|
||||
other: "Has votado <span>%{count}</span> proyectos."
|
||||
@@ -151,6 +152,7 @@ es:
|
||||
wrong_price_format: Solo puede incluir caracteres numéricos
|
||||
investment:
|
||||
add: Votar
|
||||
add_label: "Votar %{investment}"
|
||||
already_added: Ya has añadido este proyecto de gasto
|
||||
support_title: Apoyar este proyecto
|
||||
supports:
|
||||
|
||||
@@ -408,6 +408,7 @@ es:
|
||||
one: 1 Comentario
|
||||
other: "%{count} Comentarios"
|
||||
support: Apoyar
|
||||
support_label: "Apoyar %{proposal}"
|
||||
support_title: Apoyar esta propuesta
|
||||
supports:
|
||||
zero: Sin apoyos
|
||||
@@ -846,9 +847,11 @@ es:
|
||||
retired_help_text: Dashboard no disponible para propuestas retiradas
|
||||
votes:
|
||||
agree: Estoy de acuerdo
|
||||
agree_label: "Estoy de acuerdo con %{title}"
|
||||
anonymous: Demasiados votos anónimos, para poder votar %{verify_account}.
|
||||
comment_unauthenticated: Necesitas %{signin} o %{signup} para poder votar.
|
||||
disagree: No estoy de acuerdo
|
||||
disagree_label: "No estoy de acuerdo con %{title}"
|
||||
organizations: Las organizaciones no pueden votar.
|
||||
supports: Apoyos
|
||||
verified_only: Las propuestas sólo pueden ser votadas por usuarios verificados, %{verify_account}.
|
||||
|
||||
47
spec/components/budgets/investments/ballot_component_spec.rb
Normal file
47
spec/components/budgets/investments/ballot_component_spec.rb
Normal 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
|
||||
@@ -4,15 +4,13 @@ describe Debates::VotesComponent do
|
||||
let(:debate) { create(:debate, title: "What about the 2030 agenda?") }
|
||||
let(:component) { Debates::VotesComponent.new(debate) }
|
||||
|
||||
describe "Agree and disagree links" do
|
||||
it "is shown as plain text to anonymous users" do
|
||||
describe "Agree and disagree buttons" do
|
||||
it "is disabled to anonymous users" do
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_content "I agree"
|
||||
expect(page).to have_content "I disagree"
|
||||
expect(page).to have_button "I agree", disabled: true
|
||||
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).not_to have_link "I agree"
|
||||
expect(page).not_to have_link "I disagree"
|
||||
end
|
||||
|
||||
it "is shown to identified users" do
|
||||
@@ -20,10 +18,26 @@ describe Debates::VotesComponent do
|
||||
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_link count: 2
|
||||
expect(page).to have_link "I agree", title: "I agree"
|
||||
expect(page).to have_link "I disagree", title: "I disagree"
|
||||
expect(page).to have_button count: 2
|
||||
expect(page).to have_button "I agree", title: "I agree"
|
||||
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."
|
||||
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
|
||||
|
||||
@@ -4,7 +4,7 @@ describe Legislation::Proposals::VotesComponent do
|
||||
let(:proposal) { create(:legislation_proposal, title: "Require wearing masks at home") }
|
||||
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
|
||||
proposal.process.update!(
|
||||
proposals_phase_start_date: 2.days.ago,
|
||||
@@ -14,18 +14,16 @@ describe Legislation::Proposals::VotesComponent do
|
||||
sign_in(create(:user))
|
||||
render_inline component
|
||||
|
||||
expect(page).not_to have_content "I agree"
|
||||
expect(page).not_to have_content "I disagree"
|
||||
expect(page).not_to have_button "I agree", disabled: :all
|
||||
expect(page).not_to have_button "I disagree", disabled: :all
|
||||
end
|
||||
|
||||
it "is shown as plain text to anonymous users" do
|
||||
it "is disabled to anonymous users" do
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_content "I agree"
|
||||
expect(page).to have_content "I disagree"
|
||||
expect(page).to have_button "I agree", disabled: true
|
||||
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).not_to have_link "I agree"
|
||||
expect(page).not_to have_link "I disagree"
|
||||
end
|
||||
|
||||
it "is shown to identified users" do
|
||||
@@ -33,10 +31,26 @@ describe Legislation::Proposals::VotesComponent do
|
||||
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_link count: 2
|
||||
expect(page).to have_link "I agree", title: "I agree"
|
||||
expect(page).to have_link "I disagree", title: "I disagree"
|
||||
expect(page).to have_button count: 2
|
||||
expect(page).to have_button "I agree", title: "I agree"
|
||||
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."
|
||||
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
|
||||
|
||||
@@ -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,8 +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_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
|
||||
|
||||
@@ -30,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
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
module Budgets
|
||||
def expect_message_organizations_cannot_vote
|
||||
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
|
||||
|
||||
def hover_over_ballot
|
||||
scroll_to find("div.ballot"), align: :bottom
|
||||
find("div.ballot").hover
|
||||
first("div.ballot p").hover
|
||||
end
|
||||
|
||||
def add_to_ballot(investment_title)
|
||||
within(".budget-investment", text: investment_title) do
|
||||
find(".add a").click
|
||||
click_button "Vote"
|
||||
expect(page).to have_content "Remove"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ module Votes
|
||||
|
||||
def expect_message_to_many_anonymous_votes
|
||||
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
|
||||
|
||||
def expect_message_only_verified_can_vote_proposals
|
||||
|
||||
@@ -81,11 +81,11 @@ describe "BudgetPolls", :with_frozen_time do
|
||||
login_as(user)
|
||||
|
||||
visit budget_investment_path(budget, investment)
|
||||
find("div.ballot").hover
|
||||
first("div.ballot p").hover
|
||||
|
||||
within("#budget_investment_#{investment.id}") do
|
||||
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
|
||||
@@ -96,7 +96,7 @@ describe "BudgetPolls", :with_frozen_time do
|
||||
visit budget_investment_path(budget, investment)
|
||||
|
||||
within("#budget_investment_#{investment.id}") do
|
||||
find(".add a").click
|
||||
click_button "Vote"
|
||||
expect(page).to have_content "Remove"
|
||||
end
|
||||
end
|
||||
@@ -106,7 +106,7 @@ describe "BudgetPolls", :with_frozen_time do
|
||||
visit budget_investment_path(budget, investment)
|
||||
|
||||
within("#budget_investment_#{investment.id}") do
|
||||
find(".add a").click
|
||||
click_button "Vote"
|
||||
expect(page).to have_content "Remove"
|
||||
end
|
||||
|
||||
@@ -123,7 +123,7 @@ describe "BudgetPolls", :with_frozen_time do
|
||||
visit budget_investment_path(budget, investment)
|
||||
|
||||
within("#budget_investment_#{investment.id}") do
|
||||
find(".add a").click
|
||||
click_button "Vote"
|
||||
expect(page).to have_content "Remove"
|
||||
end
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ describe "Ballots" do
|
||||
end
|
||||
|
||||
within("#budget_investment_#{investment.id}") do
|
||||
find(".remove a").click
|
||||
click_button "Remove vote"
|
||||
end
|
||||
|
||||
expect(page).to have_css("#total_amount", text: "€0")
|
||||
@@ -177,7 +177,7 @@ describe "Ballots" do
|
||||
end
|
||||
|
||||
within(".budget-investment", text: "More bridges") do
|
||||
click_link "Remove vote"
|
||||
click_button "Remove vote"
|
||||
end
|
||||
|
||||
within("#sidebar") do
|
||||
@@ -283,8 +283,8 @@ describe "Ballots" do
|
||||
visit budget_investments_path(budget, heading_id: california.id)
|
||||
|
||||
within(".budget-investment", text: "Early ShakeAlert") do
|
||||
find(".remove a").click
|
||||
expect(page).to have_link "Vote"
|
||||
click_button "Remove vote"
|
||||
expect(page).to have_button "Vote"
|
||||
end
|
||||
|
||||
visit budget_investments_path(budget, heading_id: new_york.id)
|
||||
@@ -449,7 +449,7 @@ describe "Ballots" do
|
||||
hover_over_ballot
|
||||
|
||||
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
|
||||
|
||||
@@ -464,7 +464,7 @@ describe "Ballots" do
|
||||
hover_over_ballot
|
||||
|
||||
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
|
||||
|
||||
@@ -515,7 +515,7 @@ describe "Ballots" do
|
||||
hover_over_ballot
|
||||
|
||||
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
|
||||
|
||||
@@ -531,7 +531,7 @@ describe "Ballots" do
|
||||
hover_over_ballot
|
||||
|
||||
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
|
||||
|
||||
@@ -546,7 +546,7 @@ describe "Ballots" do
|
||||
hover_over_ballot
|
||||
|
||||
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
|
||||
|
||||
add_to_ballot("Build replicants")
|
||||
@@ -555,7 +555,7 @@ describe "Ballots" do
|
||||
hover_over_ballot
|
||||
|
||||
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
|
||||
|
||||
@@ -571,19 +571,19 @@ describe "Ballots" do
|
||||
hover_over_ballot
|
||||
|
||||
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
|
||||
|
||||
within("#budget_investment_#{bi1.id}") do
|
||||
find(".remove a").click
|
||||
expect(page).to have_css ".add a"
|
||||
click_button "Remove vote"
|
||||
expect(page).to have_button "Vote"
|
||||
end
|
||||
|
||||
within("#budget_investment_#{bi2.id}") do
|
||||
hover_over_ballot
|
||||
|
||||
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
|
||||
|
||||
@@ -599,7 +599,7 @@ describe "Ballots" do
|
||||
hover_over_ballot
|
||||
|
||||
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
|
||||
|
||||
within("#budget_investment_#{bi1.id}_sidebar") do
|
||||
@@ -612,7 +612,7 @@ describe "Ballots" do
|
||||
hover_over_ballot
|
||||
|
||||
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
|
||||
|
||||
@@ -623,7 +623,7 @@ describe "Ballots" do
|
||||
login_as user
|
||||
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
|
||||
login_as admin_user
|
||||
@@ -639,7 +639,7 @@ describe "Ballots" do
|
||||
end
|
||||
|
||||
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_selector(".participation-not-allowed")
|
||||
@@ -647,7 +647,7 @@ describe "Ballots" do
|
||||
hover_over_ballot
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -509,7 +509,7 @@ describe "Commenting Budget::Investments" do
|
||||
visit budget_investment_path(budget, investment)
|
||||
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -525,9 +525,9 @@ describe "Commenting Budget::Investments" do
|
||||
visit budget_investment_path(budget, investment)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
@@ -543,15 +543,15 @@ describe "Commenting Budget::Investments" do
|
||||
visit budget_investment_path(budget, investment)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
find(".against a").click
|
||||
click_button "I disagree"
|
||||
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
@@ -567,15 +567,15 @@ describe "Commenting Budget::Investments" do
|
||||
visit budget_investment_path(budget, investment)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
find(".in_favor a").click
|
||||
click_button "I agree"
|
||||
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
|
||||
@@ -331,7 +331,7 @@ describe "Commenting debates" do
|
||||
fill_in "Leave your comment", with: "Probably if government approves."
|
||||
click_button "Publish reply"
|
||||
|
||||
expect(page).not_to have_selector("form")
|
||||
expect(page).not_to have_css ".comment-form"
|
||||
|
||||
within ".comment" do
|
||||
expect(page).to have_content "Probably if government approves."
|
||||
@@ -558,7 +558,7 @@ describe "Commenting debates" do
|
||||
visit debate_path(debate)
|
||||
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -574,9 +574,9 @@ describe "Commenting debates" do
|
||||
visit debate_path(debate)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
@@ -592,15 +592,15 @@ describe "Commenting debates" do
|
||||
visit debate_path(debate)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
find(".against a").click
|
||||
click_button "I disagree"
|
||||
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
@@ -616,13 +616,13 @@ describe "Commenting debates" do
|
||||
visit debate_path(debate)
|
||||
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
within(".in_favor") do
|
||||
click_button "I agree"
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
find(".in_favor a").click
|
||||
within(".in_favor") do
|
||||
click_button "I agree"
|
||||
within(".in-favor") do
|
||||
expect(page).not_to have_content "2"
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -523,7 +523,7 @@ describe "Commenting legislation questions" do
|
||||
annotation)
|
||||
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -541,9 +541,9 @@ describe "Commenting legislation questions" do
|
||||
annotation)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
@@ -561,15 +561,15 @@ describe "Commenting legislation questions" do
|
||||
annotation)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
find(".against a").click
|
||||
click_button "I disagree"
|
||||
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
@@ -587,13 +587,13 @@ describe "Commenting legislation questions" do
|
||||
annotation)
|
||||
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
within(".in_favor") do
|
||||
click_button "I agree"
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
find(".in_favor a").click
|
||||
within(".in_favor") do
|
||||
click_button "I agree"
|
||||
within(".in-favor") do
|
||||
expect(page).not_to have_content "2"
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -475,7 +475,7 @@ describe "Commenting legislation questions" do
|
||||
visit legislation_process_question_path(question.process, question)
|
||||
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -491,9 +491,9 @@ describe "Commenting legislation questions" do
|
||||
visit legislation_process_question_path(question.process, question)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
@@ -509,15 +509,15 @@ describe "Commenting legislation questions" do
|
||||
visit legislation_process_question_path(question.process, question)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
find(".against a").click
|
||||
click_button "I disagree"
|
||||
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
@@ -533,13 +533,13 @@ describe "Commenting legislation questions" do
|
||||
visit legislation_process_question_path(question.process, question)
|
||||
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
within(".in_favor") do
|
||||
click_button "I agree"
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
find(".in_favor a").click
|
||||
within(".in_favor") do
|
||||
click_button "I agree"
|
||||
within(".in-favor") do
|
||||
expect(page).not_to have_content "2"
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -453,7 +453,7 @@ describe "Commenting polls" do
|
||||
visit poll_path(poll)
|
||||
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -469,9 +469,9 @@ describe "Commenting polls" do
|
||||
visit poll_path(poll)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
@@ -487,15 +487,15 @@ describe "Commenting polls" do
|
||||
visit poll_path(poll)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
find(".against a").click
|
||||
click_button "I disagree"
|
||||
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
@@ -511,15 +511,15 @@ describe "Commenting polls" do
|
||||
visit poll_path(poll)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
find(".in_favor a").click
|
||||
click_button "I agree"
|
||||
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
|
||||
@@ -441,7 +441,7 @@ describe "Commenting proposals" do
|
||||
visit proposal_path(proposal)
|
||||
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -457,9 +457,9 @@ describe "Commenting proposals" do
|
||||
visit proposal_path(proposal)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
@@ -475,15 +475,15 @@ describe "Commenting proposals" do
|
||||
visit proposal_path(proposal)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
find(".against a").click
|
||||
click_button "I disagree"
|
||||
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
@@ -499,15 +499,15 @@ describe "Commenting proposals" do
|
||||
visit proposal_path(proposal)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
find(".in_favor a").click
|
||||
click_button "I agree"
|
||||
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
|
||||
@@ -491,7 +491,7 @@ describe "Commenting topics from proposals" do
|
||||
visit community_topic_path(proposal.community, topic)
|
||||
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -507,9 +507,9 @@ describe "Commenting topics from proposals" do
|
||||
visit community_topic_path(proposal.community, topic)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
@@ -525,15 +525,15 @@ describe "Commenting topics from proposals" do
|
||||
visit community_topic_path(proposal.community, topic)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
find(".against a").click
|
||||
click_button "I disagree"
|
||||
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
@@ -549,15 +549,15 @@ describe "Commenting topics from proposals" do
|
||||
visit community_topic_path(proposal.community, topic)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
find(".in_favor a").click
|
||||
click_button "I agree"
|
||||
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -1002,7 +1002,7 @@ describe "Commenting topics from budget investments" do
|
||||
visit community_topic_path(investment.community, topic)
|
||||
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -1018,9 +1018,9 @@ describe "Commenting topics from budget investments" do
|
||||
visit community_topic_path(investment.community, topic)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
@@ -1036,15 +1036,15 @@ describe "Commenting topics from budget investments" do
|
||||
visit community_topic_path(investment.community, topic)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
find(".against a").click
|
||||
click_button "I disagree"
|
||||
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
@@ -1060,15 +1060,15 @@ describe "Commenting topics from budget investments" do
|
||||
visit community_topic_path(investment.community, topic)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
find(".in_favor a").click
|
||||
click_button "I agree"
|
||||
|
||||
within(".in_favor") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "1"
|
||||
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"
|
||||
|
||||
@@ -19,37 +19,37 @@ describe "Votes" do
|
||||
within("#debates") do
|
||||
within("#debate_#{debate1.id}_votes") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_css("a.voted")
|
||||
expect(page).not_to have_css("a.no-voted")
|
||||
expect(page).to have_css("button.voted")
|
||||
expect(page).not_to have_css("button.no-voted")
|
||||
end
|
||||
|
||||
within(".against") do
|
||||
expect(page).to have_css("a.no-voted")
|
||||
expect(page).not_to have_css("a.voted")
|
||||
expect(page).to have_css("button.no-voted")
|
||||
expect(page).not_to have_css("button.voted")
|
||||
end
|
||||
end
|
||||
|
||||
within("#debate_#{debate2.id}_votes") do
|
||||
within(".in-favor") do
|
||||
expect(page).not_to have_css("a.voted")
|
||||
expect(page).not_to have_css("a.no-voted")
|
||||
expect(page).not_to have_css("button.voted")
|
||||
expect(page).not_to have_css("button.no-voted")
|
||||
end
|
||||
|
||||
within(".against") do
|
||||
expect(page).not_to have_css("a.no-voted")
|
||||
expect(page).not_to have_css("a.voted")
|
||||
expect(page).not_to have_css("button.no-voted")
|
||||
expect(page).not_to have_css("button.voted")
|
||||
end
|
||||
end
|
||||
|
||||
within("#debate_#{debate3.id}_votes") do
|
||||
within(".in-favor") do
|
||||
expect(page).to have_css("a.no-voted")
|
||||
expect(page).not_to have_css("a.voted")
|
||||
expect(page).to have_css("button.no-voted")
|
||||
expect(page).not_to have_css("button.voted")
|
||||
end
|
||||
|
||||
within(".against") do
|
||||
expect(page).to have_css("a.voted")
|
||||
expect(page).not_to have_css("a.no-voted")
|
||||
expect(page).to have_css("button.voted")
|
||||
expect(page).not_to have_css("button.no-voted")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -63,37 +63,37 @@ describe "Votes" do
|
||||
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "0%"
|
||||
expect(page).not_to have_css("a.voted")
|
||||
expect(page).not_to have_css("a.no-voted")
|
||||
expect(page).not_to have_css("button.voted")
|
||||
expect(page).not_to have_css("button.no-voted")
|
||||
end
|
||||
|
||||
within(".against") do
|
||||
expect(page).to have_content "0%"
|
||||
expect(page).not_to have_css("a.voted")
|
||||
expect(page).not_to have_css("a.no-voted")
|
||||
expect(page).not_to have_css("button.voted")
|
||||
expect(page).not_to have_css("button.no-voted")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Update" do
|
||||
visit debate_path(create(:debate))
|
||||
|
||||
find(".in-favor a").click
|
||||
click_button "I agree"
|
||||
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "100%"
|
||||
expect(page).to have_css("a.voted")
|
||||
expect(page).to have_css("button.voted")
|
||||
end
|
||||
|
||||
find(".against a").click
|
||||
click_button "I disagree"
|
||||
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "0%"
|
||||
expect(page).to have_css("a.no-voted")
|
||||
expect(page).to have_css("button.no-voted")
|
||||
end
|
||||
|
||||
within(".against") do
|
||||
expect(page).to have_content "100%"
|
||||
expect(page).to have_css("a.voted")
|
||||
expect(page).to have_css("button.voted")
|
||||
end
|
||||
|
||||
expect(page).to have_content "1 vote"
|
||||
@@ -102,9 +102,9 @@ describe "Votes" do
|
||||
scenario "Trying to vote multiple times" do
|
||||
visit debate_path(create(:debate))
|
||||
|
||||
find(".in-favor a").click
|
||||
click_button "I agree"
|
||||
expect(page).to have_content "1 vote"
|
||||
find(".in-favor a").click
|
||||
click_button "I agree"
|
||||
expect(page).not_to have_content "2 votes"
|
||||
|
||||
within(".in-favor") do
|
||||
@@ -127,28 +127,28 @@ describe "Votes" do
|
||||
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "50%"
|
||||
expect(page).to have_css("a.voted")
|
||||
expect(page).to have_css("button.voted")
|
||||
end
|
||||
|
||||
within(".against") do
|
||||
expect(page).to have_content "50%"
|
||||
expect(page).to have_css("a.no-voted")
|
||||
expect(page).to have_css("button.no-voted")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Create from debate show" do
|
||||
visit debate_path(create(:debate))
|
||||
|
||||
find(".in-favor a").click
|
||||
click_button "I agree"
|
||||
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "100%"
|
||||
expect(page).to have_css("a.voted")
|
||||
expect(page).to have_css("button.voted")
|
||||
end
|
||||
|
||||
within(".against") do
|
||||
expect(page).to have_content "0%"
|
||||
expect(page).to have_css("a.no-voted")
|
||||
expect(page).to have_css("button.no-voted")
|
||||
end
|
||||
|
||||
expect(page).to have_content "1 vote"
|
||||
@@ -159,16 +159,16 @@ describe "Votes" do
|
||||
visit debates_path
|
||||
|
||||
within("#debates") do
|
||||
find(".in-favor a").click
|
||||
click_button "I agree"
|
||||
|
||||
within(".in-favor") do
|
||||
expect(page).to have_content "100%"
|
||||
expect(page).to have_css("a.voted")
|
||||
expect(page).to have_css("button.voted")
|
||||
end
|
||||
|
||||
within(".against") do
|
||||
expect(page).to have_content "0%"
|
||||
expect(page).to have_css("a.no-voted")
|
||||
expect(page).to have_css("button.no-voted")
|
||||
end
|
||||
|
||||
expect(page).to have_content "1 vote"
|
||||
@@ -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