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 4f98fb1
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 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
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
10 changes: 10 additions & 0 deletions spec/components/budgets/investments/ballot_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,19 @@
expect(page).to have_button count: 1
expect(page).to have_button "Vote", title: "Support this project"
expect(page).to have_button "Vote New Sports Center"
expect(page).to have_content "€10"
expect(page).not_to have_button "Remove vote", disabled: :all
end

it "is not shown price when the budget has hidey_money active" do
budget.update!(voting_style: "approval", hide_money: true)
sign_in(create(:user, :level_two))

render_inline component

expect(page).not_to have_content "€10"
end

it "is replaced with a button to remove the vote when the user has already voted" do
sign_in(create(:user, :level_two, ballot_lines: [investment]))

Expand Down
9 changes: 9 additions & 0 deletions spec/system/budgets/investments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,15 @@ def investments_order
expect(page).to have_current_path(/page=1/)
end

scenario "do not render order by_price when the budget has hidey_money active" do
budget.update!(voting_style: "approval", hide_money: true)

visit budget_investments_path(budget, heading_id: heading.id)

expect(page).not_to have_link "by price"
expect(page).to have_selector("a.is-active", text: "random")
end

scenario "Show" do
user = create(:user, :level_two)
investment = create(:budget_investment, :selected, heading: heading, price: 10000)
Expand Down

0 comments on commit 4f98fb1

Please sign in to comment.