Commit 93b88dd7 authored by Mario de la Ossa's avatar Mario de la Ossa

Fix Iteration due_date_passed

We had `<=` in due_date_passed when it should have been `<` as we do not
want Date.today to count as the due date having passed already.
parent 0a0557a3
......@@ -36,8 +36,8 @@ class Iteration < ApplicationRecord
.where('due_date is NULL or due_date >= ?', start_date)
end
scope :start_date_passed, -> { where('start_date <= ?', Date.current).where('due_date > ?', Date.current) }
scope :due_date_passed, -> { where('due_date <= ?', Date.current) }
scope :start_date_passed, -> { where('start_date <= ?', Date.current).where('due_date >= ?', Date.current) }
scope :due_date_passed, -> { where('due_date < ?', Date.current) }
state_machine :state_enum, initial: :upcoming do
event :start do
......
---
title: Fix for Iterations closing a day early
merge_request: 40884
author:
type: fixed
......@@ -28,14 +28,17 @@ RSpec.describe IterationsUpdateStatusWorker do
end
context 'when iterations are in `started` state' do
let_it_be(:iteration) { create(:iteration, :skip_future_date_validation, start_date: 10.days.ago, due_date: 1.day.ago, state_enum: ::Iteration::STATE_ENUM_MAP[:started]) }
let_it_be(:iteration1) { create(:iteration, :skip_future_date_validation, start_date: 10.days.ago, due_date: 2.days.ago, state_enum: ::Iteration::STATE_ENUM_MAP[:started]) }
let_it_be(:iteration2) { create(:iteration, :skip_future_date_validation, start_date: 1.day.ago, due_date: Date.today, state_enum: ::Iteration::STATE_ENUM_MAP[:started]) }
it 'updates from started to closed when due date is past' do
expect(iteration.state).to eq('started')
it 'updates from started to closed when due date is past, does not touch others', :aggregate_failures do
expect(iteration1.state).to eq('started')
expect(iteration2.state).to eq('started')
worker.perform
expect(iteration.reload.state).to eq('closed')
expect(iteration1.reload.state).to eq('closed')
expect(iteration2.reload.state).to eq('started')
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment