Fix crash in valuation when there are no budgets

This commit is contained in:
Javi Martín
2018-12-21 17:23:53 +01:00
parent b0f1b6245e
commit fd681c17df
4 changed files with 41 additions and 28 deletions

View File

@@ -1,30 +1,36 @@
<h2 class="inline-block"><%= t("valuation.budgets.index.title") %></h2>
<table>
<thead>
<tr>
<th><%= t("valuation.budgets.index.table_name") %></th>
<th><%= t("valuation.budgets.index.table_phase") %></th>
<th><%= t("valuation.budgets.index.table_assigned_investments_valuation_open") %></th>
<th><%= t("valuation.budgets.index.table_actions") %></th>
</tr>
</thead>
<tbody>
<tr id="<%= dom_id(@budget) %>" class="budget">
<td>
<%= @budget.name %>
</td>
<td>
<%= t("budgets.phase.#{@budget.phase}") %>
</td>
<td>
<%= @investments.count %>
</td>
<td>
<%= link_to t("valuation.budgets.index.evaluate"),
valuation_budget_budget_investments_path(budget_id: @budget.id),
class: "button hollow expanded" %>
</td>
</tr>
</tbody>
</table>
<% if @budget.present? %>
<table>
<thead>
<tr>
<th><%= t("valuation.budgets.index.table_name") %></th>
<th><%= t("valuation.budgets.index.table_phase") %></th>
<th><%= t("valuation.budgets.index.table_assigned_investments_valuation_open") %></th>
<th><%= t("valuation.budgets.index.table_actions") %></th>
</tr>
</thead>
<tbody>
<tr id="<%= dom_id(@budget) %>" class="budget">
<td>
<%= @budget.name %>
</td>
<td>
<%= t("budgets.phase.#{@budget.phase}") %>
</td>
<td>
<%= @investments.count %>
</td>
<td>
<%= link_to t("valuation.budgets.index.evaluate"),
valuation_budget_budget_investments_path(budget_id: @budget.id),
class: "button hollow expanded" %>
</td>
</tr>
</tbody>
</table>
<% else %>
<div class="callout primary clear">
<%= t("valuation.budgets.index.no_budgets") %>
</div>
<% end %>

View File

@@ -17,6 +17,7 @@ en:
table_assigned_investments_valuation_open: Investment projects assigned with valuation open
table_actions: Actions
evaluate: Evaluate
no_budgets: "There are no budgets"
budget_investments:
index:
headings_filter_all: All headings

View File

@@ -17,6 +17,7 @@ es:
table_assigned_investments_valuation_open: Prop. Inv. asignadas en evaluación
table_actions: Acciones
evaluate: Evaluar
no_budgets: "No hay presupuestos"
budget_investments:
index:
headings_filter_all: Todas las partidas

View File

@@ -35,6 +35,11 @@ feature 'Valuation budgets' do
expect(page).to have_content(budget3.name)
end
scenario "With no budgets" do
visit valuation_budgets_path
expect(page).to have_content "There are no budgets"
end
end
end