Skip to content

Commit

Permalink
Do not show money with hidden money
Browse files Browse the repository at this point in the history
  • Loading branch information
decabeza authored and taitus committed Feb 20, 2023
1 parent 4debff7 commit 115ffc6
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 11 deletions.
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
4 changes: 3 additions & 1 deletion app/views/budgets/ballot/_progress_bar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@
</div>

<p id="amount_available" class="amount-available" style="width: <%= ballot.percentage_spent(heading) %>%">
<%= sanitize(ballot.amount_available_info(heading)) %>
<% if @budget.show_money? %>
<%= sanitize(ballot.amount_available_info(heading)) %>
<% end %>
</p>
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
36 changes: 36 additions & 0 deletions spec/system/budgets/investments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,42 @@ def investments_order
end
end

scenario "Do not show progress bar money or price with hidden money" do
budget_hide_money = create(:budget, :hide_money, phase: "balloting", voting_style: "approval")
group = create(:budget_group, budget: budget_hide_money)
heading = create(:budget_heading, name: "Heading without money", group: group)
user = create(:user, :level_two)
investment = create(:budget_investment, :feasible, :selected, budget: budget_hide_money,
heading: heading, price: 100)

visit budget_investments_path(budget_hide_money, heading: heading)

expect(page).not_to have_content budget.formatted_heading_price(heading).to_s
expect(page).not_to have_content "€"
expect(page).not_to have_css(".tagline")

within "#budget_investment_#{investment.id}" do
expect(page).not_to have_content "100"
expect(page).not_to have_content "€"
end

login_as(user)

visit budget_investments_path(budget_hide_money, heading: heading)

expect(page).to have_content "VOTES CAST: 0 / YOU CAN VOTE 1 PROJECT"
expect(page).not_to have_content "Available budget"

expect(page).to have_css("#progress_bar")
expect(page).to have_css("#amount_available")
expect(page).not_to have_css("#amount_spent")

within "#budget_investment_#{investment.id}" do
expect(page).not_to have_content "100"
expect(page).not_to have_content "€"
end
end

scenario "Highlight voted heading" do
budget.update!(phase: "balloting")
user = create(:user, :level_two)
Expand Down

0 comments on commit 115ffc6

Please sign in to comment.