Merge pull request #3128 from consul/fix_valuation_with_no_budgets
Fix crash in valuation when there are no budgets
This commit is contained in:
@@ -7,11 +7,9 @@ class Valuation::BudgetsController < Valuation::BaseController
|
|||||||
def index
|
def index
|
||||||
@budget = current_budget
|
@budget = current_budget
|
||||||
if @budget.present?
|
if @budget.present?
|
||||||
@investments_with_valuation_open = {}
|
@investments = @budget.investments
|
||||||
@investments_with_valuation_open = @budget.investments
|
.by_valuator(current_user.valuator)
|
||||||
.by_valuator(current_user.valuator.try(:id))
|
|
||||||
.valuation_open
|
.valuation_open
|
||||||
.count
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<h2 class="inline-block"><%= t("valuation.budgets.index.title") %></h2>
|
<h2 class="inline-block"><%= t("valuation.budgets.index.title") %></h2>
|
||||||
|
|
||||||
|
<% if @budget.present? %>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -18,7 +19,7 @@
|
|||||||
<%= t("budgets.phase.#{@budget.phase}") %>
|
<%= t("budgets.phase.#{@budget.phase}") %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= @investments_with_valuation_open %>
|
<%= @investments.count %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to t("valuation.budgets.index.evaluate"),
|
<%= link_to t("valuation.budgets.index.evaluate"),
|
||||||
@@ -28,3 +29,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<% else %>
|
||||||
|
<div class="callout primary clear">
|
||||||
|
<%= t("valuation.budgets.index.no_budgets") %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ en:
|
|||||||
table_assigned_investments_valuation_open: Investment projects assigned with valuation open
|
table_assigned_investments_valuation_open: Investment projects assigned with valuation open
|
||||||
table_actions: Actions
|
table_actions: Actions
|
||||||
evaluate: Evaluate
|
evaluate: Evaluate
|
||||||
|
no_budgets: "There are no budgets"
|
||||||
budget_investments:
|
budget_investments:
|
||||||
index:
|
index:
|
||||||
headings_filter_all: All headings
|
headings_filter_all: All headings
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ es:
|
|||||||
table_assigned_investments_valuation_open: Prop. Inv. asignadas en evaluación
|
table_assigned_investments_valuation_open: Prop. Inv. asignadas en evaluación
|
||||||
table_actions: Acciones
|
table_actions: Acciones
|
||||||
evaluate: Evaluar
|
evaluate: Evaluar
|
||||||
|
no_budgets: "No hay presupuestos"
|
||||||
budget_investments:
|
budget_investments:
|
||||||
index:
|
index:
|
||||||
headings_filter_all: Todas las partidas
|
headings_filter_all: Todas las partidas
|
||||||
|
|||||||
@@ -35,6 +35,11 @@ feature 'Valuation budgets' do
|
|||||||
expect(page).to have_content(budget3.name)
|
expect(page).to have_content(budget3.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "With no budgets" do
|
||||||
|
visit valuation_budgets_path
|
||||||
|
|
||||||
|
expect(page).to have_content "There are no budgets"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user