diff --git a/app/components/budgets/investments/votes_component.html.erb b/app/components/budgets/investments/votes_component.html.erb
index 8b84af637..70ffbfe96 100644
--- a/app/components/budgets/investments/votes_component.html.erb
+++ b/app/components/budgets/investments/votes_component.html.erb
@@ -10,29 +10,36 @@
<%= t("budgets.investments.investment.already_supported") %>
<% elsif investment.should_show_votes? %>
- <%= link_to t("budgets.investments.investment.give_support"), vote_url,
- class: "button button-support small expanded",
- title: t("budgets.investments.investment.support_title"),
- method: "post",
- remote: !display_support_alert?,
- data: ({ confirm: confirm_vote_message } if display_support_alert?),
- "aria-hidden" => css_for_aria_hidden %>
+ <% if current_user %>
+ <%= link_to t("budgets.investments.investment.give_support"), vote_url,
+ class: "button button-support small expanded",
+ title: t("budgets.investments.investment.support_title"),
+ method: "post",
+ remote: !display_support_alert?,
+ data: ({ confirm: confirm_vote_message } if display_support_alert?) %>
+ <% else %>
+
+ <%= t("budgets.investments.investment.give_support") %>
+
+ <% end %>
<% end %>
<% if reason.present? && !user_voted_for? %>
-
-
-
- <%= sanitize(t("votes.budget_investments.#{reason}",
- count: investment.group.max_votable_headings,
- verify_account: link_to_verify_account,
- signin: link_to_signin,
- signup: link_to_signup,
- supported_headings: (current_user && current_user.headings_voted_within_group(investment.group).map(&:name).sort.to_sentence)
- )) %>
-
-
+
+
+
+
+ <%= sanitize(t("votes.budget_investments.#{reason}",
+ count: investment.group.max_votable_headings,
+ verify_account: link_to_verify_account,
+ signin: link_to_signin,
+ signup: link_to_signup,
+ supported_headings: (current_user && current_user.headings_voted_within_group(investment.group).map(&:name).sort.to_sentence)
+ )) %>
+
+
+
<% end %>
diff --git a/app/components/budgets/investments/votes_component.rb b/app/components/budgets/investments/votes_component.rb
index 319cef81e..1b3440d6c 100644
--- a/app/components/budgets/investments/votes_component.rb
+++ b/app/components/budgets/investments/votes_component.rb
@@ -32,8 +32,4 @@ class Budgets::Investments::VotesComponent < ApplicationComponent
def confirm_vote_message
t("budgets.investments.investment.confirm_group", count: investment.group.max_votable_headings)
end
-
- def css_for_aria_hidden
- reason.present? ? "true" : ""
- end
end
diff --git a/spec/components/budgets/investments/votes_component_spec.rb b/spec/components/budgets/investments/votes_component_spec.rb
new file mode 100644
index 000000000..b352fa56f
--- /dev/null
+++ b/spec/components/budgets/investments/votes_component_spec.rb
@@ -0,0 +1,31 @@
+require "rails_helper"
+
+describe Budgets::Investments::VotesComponent, type: :component do
+ describe "vote link" do
+ context "when investment shows votes" do
+ let(:investment) { create(:budget_investment) }
+ let(:component) do
+ Budgets::Investments::VotesComponent.new(investment, investment_votes: [], vote_url: "/")
+ end
+
+ before { allow(investment).to receive(:should_show_votes?).and_return(true) }
+
+ it "displays a link to support the investment to identified users" do
+ allow(controller).to receive(:current_user).and_return(create(:user))
+
+ render_inline component
+
+ expect(page).to have_link "Support"
+ end
+
+ it "does not display link to support the investment to unidentified users" do
+ allow(controller).to receive(:current_user).and_return(nil)
+
+ render_inline component
+
+ expect(page).not_to have_link "Support"
+ expect(page).to have_content "Support"
+ end
+ end
+ end
+end