Manage the render of the price field on admin investments section

This commit is contained in:
decabeza
2022-02-02 13:36:08 +01:00
committed by taitus
parent 2c16bac5f8
commit 40bdd1f03a
3 changed files with 21 additions and 4 deletions

View File

@@ -30,7 +30,9 @@
</th> </th>
<th data-field="geozone"><%= t("admin.budget_investments.index.list.geozone") %></th> <th data-field="geozone"><%= t("admin.budget_investments.index.list.geozone") %></th>
<th data-field="feasibility"><%= t("admin.budget_investments.index.list.feasibility") %></th> <th data-field="feasibility"><%= t("admin.budget_investments.index.list.feasibility") %></th>
<% if @budget.show_money? %>
<th data-field="price"><%= t("admin.budget_investments.index.list.price") %></th> <th data-field="price"><%= t("admin.budget_investments.index.list.price") %></th>
<% end %>
<th data-field="valuation_finished"> <th data-field="valuation_finished">
<%= t("admin.budget_investments.index.list.valuation_finished") %> <%= t("admin.budget_investments.index.list.valuation_finished") %>
</th> </th>

View File

@@ -42,9 +42,11 @@
<%= t("admin.budget_investments.index.feasibility.#{investment.feasibility}") %> <%= t("admin.budget_investments.index.feasibility.#{investment.feasibility}") %>
</td> </td>
<% if @budget.show_money? %>
<td class="small" data-field="price"> <td class="small" data-field="price">
<%= investment.formatted_price %> <%= investment.formatted_price %>
</td> </td>
<% end %>
<td class="small text-center" data-field="valuation_finished"> <td class="small text-center" data-field="valuation_finished">
<%= investment.valuation_finished? ? t("shared.yes") : t("shared.no") %> <%= investment.valuation_finished? ? t("shared.yes") : t("shared.no") %>

View File

@@ -30,6 +30,19 @@ describe "Admin budget investments", :admin do
expect(page).to have_content(budget_investment.total_votes) expect(page).to have_content(budget_investment.total_votes)
end end
scenario "Do not show price column on budgets with hide money" do
budget_hide_money = create(:budget, :hide_money)
budget_investment = create(:budget_investment, budget: budget_hide_money)
visit admin_budget_budget_investments_path(budget_hide_money)
expect(page).to have_content(budget_investment.title)
expect(page).to have_content(budget_investment.heading.name)
expect(page).to have_content(budget_investment.id)
expect(page).not_to have_content("Price")
expect(page).not_to have_content("")
end
scenario "If budget is finished do not show 'Selected' button" do scenario "If budget is finished do not show 'Selected' button" do
finished_budget = create(:budget, :finished) finished_budget = create(:budget, :finished)
budget_investment = create(:budget_investment, budget: finished_budget, cached_votes_up: 77) budget_investment = create(:budget_investment, budget: finished_budget, cached_votes_up: 77)