diff --git a/app/components/budgets/investments/ballot_component.html.erb b/app/components/budgets/investments/ballot_component.html.erb
index 7331a5176511..2f609e14641e 100644
--- a/app/components/budgets/investments/ballot_component.html.erb
+++ b/app/components/budgets/investments/ballot_component.html.erb
@@ -4,9 +4,11 @@
">
-
- <%= investment.formatted_price %>
-
+ <% if investment.should_show_price? %>
+
+ <%= investment.formatted_price %>
+
+ <% end %>
<% if investment.should_show_ballots? %>
<%= button_to budget_ballot_line_path(id: investment.id,
budget_id: investment.budget_id,
@@ -21,9 +23,11 @@
<% else %>
-
- <%= investment.formatted_price %>
-
+ <% if investment.should_show_price? %>
+
+ <%= investment.formatted_price %>
+
+ <% end %>
<% if investment.should_show_ballots? %>
<%= button_to budget_ballot_lines_path(investment_id: investment.id,
budget_id: investment.budget_id,
diff --git a/app/views/budgets/investments/_header.html.erb b/app/views/budgets/investments/_header.html.erb
index 5a2b582a50b0..5f1ab18b892b 100644
--- a/app/views/budgets/investments/_header.html.erb
+++ b/app/views/budgets/investments/_header.html.erb
@@ -51,10 +51,12 @@
<%= t("budgets.investments.index.by_heading", heading: @heading.name) %>
-
- <%= t("budgets.investments.header.price") %>
- <%= @budget.formatted_heading_price(@heading) %>
-
+ <% if @budget.show_money? %>
+
+ <%= t("budgets.investments.header.price") %>
+ <%= @budget.formatted_heading_price(@heading) %>
+
+ <% end %>
<% end %>
diff --git a/spec/components/budgets/investments/ballot_component_spec.rb b/spec/components/budgets/investments/ballot_component_spec.rb
index 347380954719..01a87956f259 100644
--- a/spec/components/budgets/investments/ballot_component_spec.rb
+++ b/spec/components/budgets/investments/ballot_component_spec.rb
@@ -43,4 +43,44 @@
expect(page).not_to have_button "Vote", disabled: :all
end
end
+
+ describe "price" do
+ let(:budget) { create(:budget, :approval, :balloting) }
+ let(:investment) { create(:budget_investment, :selected, price: 20, 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!
+ )
+ end
+
+ it "is shown price when the budget has not hidey_money active" do
+ sign_in(create(:user, :level_two))
+
+ render_inline component
+
+ expect(page).to have_content "€20"
+ end
+
+ describe "is not shown price when the budget has hidey_money active" do
+ before { budget.update!(hide_money: true) }
+
+ it "user has already voted" do
+ sign_in(create(:user, :level_two, ballot_lines: [investment]))
+
+ render_inline component
+
+ expect(page).not_to have_content "€20"
+ end
+
+ it "user has not already voted" do
+ sign_in(create(:user, :level_two))
+
+ render_inline component
+
+ expect(page).not_to have_content "€20"
+ end
+ end
+ end
end
diff --git a/spec/system/budgets/investments_spec.rb b/spec/system/budgets/investments_spec.rb
index 07d35acaf197..405f6e15b269 100644
--- a/spec/system/budgets/investments_spec.rb
+++ b/spec/system/budgets/investments_spec.rb
@@ -1498,6 +1498,29 @@ def investments_order
end
end
+ describe "total amount" do
+ before do
+ budget.update!(voting_style: "approval")
+ heading.update!(price: 2000)
+ end
+
+ scenario "Do not show total budget amount for budget with hidden money" do
+ budget.update!(hide_money: true)
+
+ visit budget_investments_path(budget, heading_id: heading)
+
+ expect(page).not_to have_content "Total budget"
+ expect(page).not_to have_content "€2,000"
+ end
+
+ scenario "Show total budget amount for budget without hidden money" do
+ visit budget_investments_path(budget, heading_id: heading)
+
+ expect(page).to have_content "Total budget"
+ expect(page).to have_content "€2,000"
+ end
+ end
+
scenario "Highlight voted heading" do
budget.update!(phase: "balloting")
user = create(:user, :level_two)