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:
@@ -73,7 +73,9 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
||||
end
|
||||
|
||||
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)
|
||||
.order(name: :asc)
|
||||
|
||||
|
||||
@@ -93,25 +93,25 @@ feature 'Valuation budget investments' do
|
||||
valuating_finished_heading = create(:budget_heading, name: "Valuating&Finished", group: group)
|
||||
finished_heading = create(:budget_heading, name: "Only Finished", group: group)
|
||||
create(:budget_investment, :visible_to_valuators, title: "Valuating Investment ONE",
|
||||
heading: valuating_heading,
|
||||
group: group,
|
||||
budget: budget,
|
||||
valuators: [valuator])
|
||||
heading: valuating_heading,
|
||||
group: group,
|
||||
budget: budget,
|
||||
valuators: [valuator])
|
||||
create(:budget_investment, :visible_to_valuators, title: "Valuating Investment TWO",
|
||||
heading: valuating_finished_heading,
|
||||
group: group,
|
||||
budget: budget,
|
||||
valuators: [valuator])
|
||||
create(:budget_investment, :finished, :visible_to_valuators, title: "Finished ONE",
|
||||
heading: valuating_finished_heading,
|
||||
group: group,
|
||||
budget: budget,
|
||||
valuators: [valuator])
|
||||
create(:budget_investment, :finished, :visible_to_valuators, title: "Finished TWO",
|
||||
heading: finished_heading,
|
||||
group: group,
|
||||
budget: budget,
|
||||
valuators: [valuator])
|
||||
heading: valuating_finished_heading,
|
||||
group: group,
|
||||
budget: budget,
|
||||
valuators: [valuator])
|
||||
create(:budget_investment, :visible_to_valuators, :finished, title: "Finished ONE",
|
||||
heading: valuating_finished_heading,
|
||||
group: group,
|
||||
budget: budget,
|
||||
valuators: [valuator])
|
||||
create(:budget_investment, :visible_to_valuators, :finished, title: "Finished TWO",
|
||||
heading: finished_heading,
|
||||
group: group,
|
||||
budget: budget,
|
||||
valuators: [valuator])
|
||||
|
||||
visit valuation_budget_budget_investments_path(budget)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user