diff --git a/app/controllers/valuation/budget_investments_controller.rb b/app/controllers/valuation/budget_investments_controller.rb index bf70d657b..d8b832d47 100644 --- a/app/controllers/valuation/budget_investments_controller.rb +++ b/app/controllers/valuation/budget_investments_controller.rb @@ -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) diff --git a/spec/features/valuation/budget_investments_spec.rb b/spec/features/valuation/budget_investments_spec.rb index 5d9b4fa4a..b5b381779 100644 --- a/spec/features/valuation/budget_investments_spec.rb +++ b/spec/features/valuation/budget_investments_spec.rb @@ -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)