Commit dd2b277f authored by Eulyeon Ko's avatar Eulyeon Ko

Remove hardcoding iteration period in titles

Auto-generated iterations for a cadence had
start/due date hardcoded into their titles.

We are removing the hardcoding logic.
parent 2d81033a
...@@ -55,7 +55,6 @@ module Iterations ...@@ -55,7 +55,6 @@ module Iterations
# we end up having 2020-01-01(beginning of day) - 2020-01-07(end of day) # we end up having 2020-01-01(beginning of day) - 2020-01-07(end of day)
start_date = next_start_date start_date = next_start_date
due_date = start_date + duration.weeks - 1.day due_date = start_date + duration.weeks - 1.day
title = "Iteration #{iteration_number}: #{format_period(start_date, due_date)}"
{ {
iid: iid, iid: iid,
...@@ -66,7 +65,7 @@ module Iterations ...@@ -66,7 +65,7 @@ module Iterations
start_date: start_date, start_date: start_date,
due_date: due_date, due_date: due_date,
state_enum: Iteration::STATE_ENUM_MAP[::Iteration.compute_state(start_date, due_date)], state_enum: Iteration::STATE_ENUM_MAP[::Iteration.compute_state(start_date, due_date)],
title: title title: "Iteration #{iteration_number}"
} }
end end
...@@ -122,11 +121,8 @@ module Iterations ...@@ -122,11 +121,8 @@ module Iterations
existing_iterations_in_advance.each do |iteration| existing_iterations_in_advance.each do |iteration|
if iteration.duration_in_days != cadence.duration_in_days if iteration.duration_in_days != cadence.duration_in_days
old_title_dates_substring = format_period(iteration.start_date, iteration.due_date)
iteration.start_date = prev_iteration.due_date + 1.day if prev_iteration iteration.start_date = prev_iteration.due_date + 1.day if prev_iteration
iteration.due_date = iteration.start_date + cadence.duration_in_days.days - 1.day iteration.due_date = iteration.start_date + cadence.duration_in_days.days - 1.day
new_title_dates_substring = format_period(iteration.start_date, iteration.due_date)
iteration.title = iteration.title.gsub(old_title_dates_substring, new_title_dates_substring)
end end
prev_iteration = iteration prev_iteration = iteration
...@@ -141,12 +137,6 @@ module Iterations ...@@ -141,12 +137,6 @@ module Iterations
end end
end end
def format_period(start_date, due_date)
format = Date::DATE_FORMATS[:long]
"#{start_date.strftime(format)} - #{due_date.strftime(format)}"
end
def compute_last_run_date def compute_last_run_date
reloaded_last_iteration = cadence_iterations.last reloaded_last_iteration = cadence_iterations.last
run_date = reloaded_last_iteration.due_date - ((cadence.iterations_in_advance - 1) * cadence.duration_in_weeks).weeks if reloaded_last_iteration run_date = reloaded_last_iteration.due_date - ((cadence.iterations_in_advance - 1) * cadence.duration_in_weeks).weeks if reloaded_last_iteration
......
...@@ -162,15 +162,12 @@ RSpec.describe Iterations::Cadences::CreateIterationsInAdvanceService do ...@@ -162,15 +162,12 @@ RSpec.describe Iterations::Cadences::CreateIterationsInAdvanceService do
it 'sets the title correctly based on iterations count and follow-up dates' do it 'sets the title correctly based on iterations count and follow-up dates' do
subject subject
initial_start_date = past_iteration2.due_date + 1.day
initial_due_date = past_iteration2.due_date + 1.week
expect(group.reload.iterations.due_date_order_asc.pluck(:title)).to eq([ expect(group.reload.iterations.due_date_order_asc.pluck(:title)).to eq([
'Iteration 1', 'Iteration 1',
'Iteration 2', 'Iteration 2',
"Iteration 3: #{(initial_start_date).strftime(Date::DATE_FORMATS[:long])} - #{initial_due_date.strftime(Date::DATE_FORMATS[:long])}", "Iteration 3",
"Iteration 4: #{(initial_due_date + 1.day).strftime(Date::DATE_FORMATS[:long])} - #{(initial_due_date + 1.week).strftime(Date::DATE_FORMATS[:long])}", "Iteration 4",
"Iteration 5: #{(initial_due_date + 1.week + 1.day).strftime(Date::DATE_FORMATS[:long])} - #{(initial_due_date + 2.weeks).strftime(Date::DATE_FORMATS[:long])}" "Iteration 5"
]) ])
end end
...@@ -181,20 +178,17 @@ RSpec.describe Iterations::Cadences::CreateIterationsInAdvanceService do ...@@ -181,20 +178,17 @@ RSpec.describe Iterations::Cadences::CreateIterationsInAdvanceService do
automated_cadence.reload automated_cadence.reload
end end
it 'adjusts iteration titles for iterations that are autogenerated and have the dates in the title' do it 'adjusts iteration titles for iterations that are autogenerated' do
subject subject
# change duration and expect the titles for iterations containing dates in title to change # change duration and expect the titles for iterations containing dates in title to change
described_class.new(user, automated_cadence).execute described_class.new(user, automated_cadence).execute
initial_start_date = past_iteration2.due_date + 1.day
initial_due_date = past_iteration2.due_date + 1.week
expect(group.reload.iterations.due_date_order_asc.pluck(:title)).to eq([ expect(group.reload.iterations.due_date_order_asc.pluck(:title)).to eq([
'Iteration 1', 'Iteration 1',
'Iteration 2', 'Iteration 2',
"Iteration 3: #{(initial_start_date).strftime(Date::DATE_FORMATS[:long])} - #{initial_due_date.strftime(Date::DATE_FORMATS[:long])}", "Iteration 3",
"Iteration 4: #{(initial_due_date + 1.day).strftime(Date::DATE_FORMATS[:long])} - #{(initial_due_date + 3.weeks).strftime(Date::DATE_FORMATS[:long])}", "Iteration 4",
"Iteration 5: #{(initial_due_date + 3.weeks + 1.day).strftime(Date::DATE_FORMATS[:long])} - #{(initial_due_date + 6.weeks).strftime(Date::DATE_FORMATS[:long])}" "Iteration 5"
]) ])
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