Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not show money with hidden money #4900

Merged
merged 1 commit into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions app/components/budgets/investments/ballot_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
<span class="icon-check-circle"
title="<%= t("budgets.investments.investment.already_added") %>">
</span>
<p class="investment-project-amount">
<%= investment.formatted_price %>
</p>
<% if investment.should_show_price? %>
<p class="investment-project-amount">
<%= investment.formatted_price %>
</p>
<% end %>
<% if investment.should_show_ballots? %>
<%= button_to budget_ballot_line_path(id: investment.id,
budget_id: investment.budget_id,
Expand All @@ -21,9 +23,11 @@
</div>
<% else %>
<div class="add in-favor">
<p class="investment-project-amount">
<%= investment.formatted_price %>
</p>
<% if investment.should_show_price? %>
<p class="investment-project-amount">
<%= investment.formatted_price %>
</p>
<% end %>
<% if investment.should_show_ballots? %>
<%= button_to budget_ballot_lines_path(investment_id: investment.id,
budget_id: investment.budget_id,
Expand Down
10 changes: 6 additions & 4 deletions app/views/budgets/investments/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@
<h2 class="margin-top">
<%= t("budgets.investments.index.by_heading", heading: @heading.name) %>
</h2>
<h3>
<span class="tagline"><%= t("budgets.investments.header.price") %></span>
<%= @budget.formatted_heading_price(@heading) %>
</h3>
<% if @budget.show_money? %>
<h3>
<span class="tagline"><%= t("budgets.investments.header.price") %></span>
<%= @budget.formatted_heading_price(@heading) %>
</h3>
<% end %>
<% end %>
</div>
</div>
Expand Down
40 changes: 40 additions & 0 deletions spec/components/budgets/investments/ballot_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 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

context "when the budget has hidey_money active" do
before { budget.update!(hide_money: true) }

it "is not shown when the 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 "is not shown when the 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
23 changes: 23 additions & 0 deletions spec/system/budgets/investments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down