Fix Valuation Investment index heading filters

Why:

Heading filter where not being correctly displayed

How:

Increasing scenario to cover all possible combinations, and fixing the
heading_filters method of the Valuation Budget Investment Controller to
correctly:
  * Find how many investments the valuator can access
  * Count investments for each heading
This commit is contained in:
Bertocq
2018-03-13 19:58:40 +01:00
committed by decabeza
parent 06831f4fc9
commit 3e75bd4dfd
2 changed files with 21 additions and 19 deletions

View File

@@ -73,7 +73,9 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
end end
def heading_filters def heading_filters
investments = @budget.investments.by_valuator(current_user.valuator.try(:id)).distinct investments = @budget.investments.by_valuator(current_user.valuator.try(:id))
.visible_to_valuators.distinct
investment_headings = Budget::Heading.where(id: investments.pluck(:heading_id).uniq) investment_headings = Budget::Heading.where(id: investments.pluck(:heading_id).uniq)
.order(name: :asc) .order(name: :asc)

View File

@@ -102,12 +102,12 @@ feature 'Valuation budget investments' do
group: group, group: group,
budget: budget, budget: budget,
valuators: [valuator]) valuators: [valuator])
create(:budget_investment, :finished, :visible_to_valuators, title: "Finished ONE", create(:budget_investment, :visible_to_valuators, :finished, title: "Finished ONE",
heading: valuating_finished_heading, heading: valuating_finished_heading,
group: group, group: group,
budget: budget, budget: budget,
valuators: [valuator]) valuators: [valuator])
create(:budget_investment, :finished, :visible_to_valuators, title: "Finished TWO", create(:budget_investment, :visible_to_valuators, :finished, title: "Finished TWO",
heading: finished_heading, heading: finished_heading,
group: group, group: group,
budget: budget, budget: budget,