Fix exception when no available milestones
We were getting an exception when quering[1] for milestones which were not present, due to for example having a publication date later than today
Adding a `try` statement and spec to avoid this situation
[1] 82efc3dd66/app/controllers/budgets/executions_controller.rb (L16)
This commit is contained in:
@@ -13,7 +13,7 @@ module Budgets
|
||||
.joins(:milestones).includes(:milestones)
|
||||
.select { |i| i.milestones.published.with_status
|
||||
.order_by_publication_date.last
|
||||
.status_id == params[:status].to_i }
|
||||
.try(:status_id) == params[:status].to_i }
|
||||
.uniq
|
||||
.group_by(&:heading)
|
||||
else
|
||||
|
||||
@@ -249,4 +249,18 @@ feature 'Executions' do
|
||||
expect(m_heading.name).to appear_before(z_heading.name)
|
||||
end
|
||||
end
|
||||
|
||||
context 'No milestones' do
|
||||
|
||||
scenario 'Milestone not yet published' do
|
||||
status = create(:budget_investment_status)
|
||||
unpublished_milestone = create(:budget_investment_milestone, investment: investment1,
|
||||
status: status, publication_date: Date.tomorrow)
|
||||
|
||||
visit custom_budget_executions_path(budget, status: status.id)
|
||||
|
||||
expect(page).to have_content('No winner investments in this state')
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user