Add investment name to vote links aria-label
Note we're using the `budgets.investments.investment.add_label` and `budgets.ballots.show.remove_label` internationalization keys so they're consistent with the `budgets.investments.investment.add` and `budgets.ballots.show.remove` keys which were already present. We aren't unifying these keys in order to keep existing translations.
This commit is contained in:
@@ -14,7 +14,8 @@
|
||||
investments_ids: investment_ids),
|
||||
class: "button button-remove-support expanded",
|
||||
method: :delete,
|
||||
remote: true %>
|
||||
remote: true,
|
||||
"aria-label": remove_vote_aria_label %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
@@ -30,7 +31,8 @@
|
||||
class: "button button-support expanded",
|
||||
title: t("budgets.investments.investment.support_title"),
|
||||
method: :post,
|
||||
remote: true %>
|
||||
remote: true,
|
||||
"aria-label": vote_aria_label %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
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 link" 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_link "Vote"
|
||||
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_link count: 1
|
||||
expect(page).to have_link "Vote", title: "Support this project"
|
||||
expect(page).to have_link "Vote New Sports Center"
|
||||
expect(page).not_to have_link "Remove vote"
|
||||
end
|
||||
|
||||
it "is replaced with a link 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_link count: 1
|
||||
expect(page).to have_link "Remove vote"
|
||||
expect(page).to have_link "Remove your vote for New Sports Center"
|
||||
expect(page).not_to have_link "Vote"
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user