From 749954267de78e6d37f587fd21fdd8366fc61cbc Mon Sep 17 00:00:00 2001 From: Angel Perez Date: Wed, 11 Jul 2018 12:41:48 -0400 Subject: [PATCH] Use Budget::Investment#winners scope to fetch only winner investments --- app/helpers/budget_executions_helper.rb | 6 ++---- spec/features/budgets/executions_spec.rb | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/helpers/budget_executions_helper.rb b/app/helpers/budget_executions_helper.rb index 1681da6f4..ec448c675 100644 --- a/app/helpers/budget_executions_helper.rb +++ b/app/helpers/budget_executions_helper.rb @@ -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 diff --git a/spec/features/budgets/executions_spec.rb b/spec/features/budgets/executions_spec.rb index 6c3b6b6b1..03bdc21ab 100644 --- a/spec/features/budgets/executions_spec.rb +++ b/spec/features/budgets/executions_spec.rb @@ -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)