Commit ee0e3709 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'iteration_due_date_passed_fix' into 'master'

Fix Iteration due_date_passed

See merge request gitlab-org/gitlab!40884
parents afec9e8d 93b88dd7
......@@ -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