Filtering investments are based on the latest milestone status
This commit is contained in:
@@ -6,7 +6,7 @@ module BudgetExecutionsHelper
|
||||
.winners
|
||||
.joins(:milestones)
|
||||
.distinct
|
||||
.where('budget_investment_milestones.status_id = ?', params[:status])
|
||||
.where(filter_investment_by_latest_milestone, params[:status])
|
||||
else
|
||||
heading.investments
|
||||
.winners
|
||||
@@ -15,4 +15,11 @@ module BudgetExecutionsHelper
|
||||
end
|
||||
end
|
||||
|
||||
def filter_investment_by_latest_milestone
|
||||
<<-SQL
|
||||
(SELECT status_id FROM budget_investment_milestones
|
||||
WHERE investment_id = budget_investments.id ORDER BY publication_date DESC LIMIT 1) = ?
|
||||
SQL
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -138,7 +138,7 @@ feature 'Executions' do
|
||||
expect(page).not_to have_content(investment2.title)
|
||||
end
|
||||
|
||||
xscenario 'are based on latest milestone status', :js do
|
||||
scenario 'are based on latest milestone status', :js do
|
||||
create(:budget_investment_milestone, investment: investment1,
|
||||
publication_date: Date.yesterday,
|
||||
status: status1)
|
||||
@@ -157,10 +157,12 @@ feature 'Executions' do
|
||||
select 'Studying the project', from: 'status'
|
||||
|
||||
expect(page).not_to have_content(investment1.title)
|
||||
expect(page).to have_content('No winner investments for this heading')
|
||||
|
||||
select 'Bidding', from: 'status'
|
||||
|
||||
expect(page).to have_content(investment1.title)
|
||||
expect(page).not_to have_content('No winner investments for this heading')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user