Use Budget::Investment#winners scope to fetch only winner investments
This commit is contained in:
@@ -3,15 +3,13 @@ module BudgetExecutionsHelper
|
||||
def winner_investments(heading)
|
||||
if params[:status].present?
|
||||
heading.investments
|
||||
.selected
|
||||
.sort_by_ballots
|
||||
.winners
|
||||
.joins(:milestones)
|
||||
.distinct
|
||||
.where('budget_investment_milestones.status_id = ?', params[:status])
|
||||
else
|
||||
heading.investments
|
||||
.selected
|
||||
.sort_by_ballots
|
||||
.winners
|
||||
.joins(:milestones)
|
||||
.distinct
|
||||
end
|
||||
|
||||
@@ -6,10 +6,10 @@ feature 'Executions' do
|
||||
let(:group) { create(:budget_group, budget: budget) }
|
||||
let(:heading) { create(:budget_heading, group: group, price: 1000) }
|
||||
|
||||
let!(:investment1) { create(:budget_investment, :selected, heading: heading, price: 200, ballot_lines_count: 900) }
|
||||
let!(:investment2) { create(:budget_investment, :selected, heading: heading, price: 300, ballot_lines_count: 800) }
|
||||
let!(:investment1) { create(:budget_investment, :winner, heading: heading, price: 200, ballot_lines_count: 900) }
|
||||
let!(:investment2) { create(:budget_investment, :winner, heading: heading, price: 300, ballot_lines_count: 800) }
|
||||
let!(:investment3) { create(:budget_investment, :incompatible, heading: heading, price: 500, ballot_lines_count: 700) }
|
||||
let!(:investment4) { create(:budget_investment, :selected, heading: heading, price: 600, ballot_lines_count: 600) }
|
||||
let!(:investment4) { create(:budget_investment, :winner, heading: heading, price: 600, ballot_lines_count: 600) }
|
||||
|
||||
scenario 'only displays investments with milestones' do
|
||||
create(:budget_investment_milestone, investment: investment1)
|
||||
|
||||
Reference in New Issue
Block a user