Display only current budget for Valuators

Before we could have multiple current budgets, as we now only have one
current_budget, some specs broke.

As there is no need to display multiple budgets to Valuators, only the
current budget is necessary, we can remove arrays and assume that only
a single budget, the current budget, is displayed to Valuators
This commit is contained in:
rgarcia
2018-01-15 20:29:49 +01:00
parent 01ef439053
commit 5086314bee
3 changed files with 26 additions and 35 deletions

View File

@@ -5,10 +5,10 @@ class Valuation::BudgetsController < Valuation::BaseController
load_and_authorize_resource
def index
@budgets = @budgets.current.order(created_at: :desc).page(params[:page])
@investments_with_valuation_open = {}
@budgets.each do |b|
@investments_with_valuation_open[b.id] = b.investments
@budget = Budget.current
if @budget.present?
@investments_with_valuation_open = {}
@investments_with_valuation_open = @budget.investments
.by_valuator(current_user.valuator.try(:id))
.valuation_open
.count