Commit a790592a authored by Alexandru Croitor's avatar Alexandru Croitor

Fix iteration state when building iterations in advance

When building iterations in advance for a given cadence we do
create iterations using bulk insert, so we do skip some callbacks
because of that we need to compute the iteration state before
inserting.
parent 45b9cfc2
......@@ -66,6 +66,7 @@ module Iterations
group_id: cadence.group_id,
start_date: start_date,
due_date: due_date,
state_enum: Iteration::STATE_ENUM_MAP[::Iteration.compute_state(start_date, due_date)],
title: title,
description: description
}
......
......@@ -173,6 +173,12 @@ RSpec.describe Iterations::Cadences::CreateIterationsInAdvanceService do
"Iteration 5: #{(initial_due_date + 1.week + 1.day).strftime(Date::DATE_FORMATS[:long])} - #{(initial_due_date + 2.weeks).strftime(Date::DATE_FORMATS[:long])}"
])
end
it 'sets the states correctly based on iterations dates' do
subject
expect(group.reload.iterations.order(:start_date).map(&:state)).to eq(%w[closed closed current upcoming upcoming])
end
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