Commit 40765c8d authored by Sean Arnold's avatar Sean Arnold

Handle rotation start time within active period

- Add specs
- Add comment for upcoming feature
parent b74bbc71
......@@ -122,6 +122,8 @@ module Mutations
parsed_from = Time.parse(start_time)
parsed_to = Time.parse(end_time)
# Overnight shift times will be supported via
# https://gitlab.com/gitlab-org/gitlab/-/issues/322079
if parsed_to < parsed_from
raise ::Gitlab::Graphql::Errors::ArgumentError, "'start_time' time must be before 'end_time' time"
end
......
......@@ -132,7 +132,7 @@ module IncidentManagement
starts_at, ends_at = rotation.active_period.for_date(shift_cycle_starts_at + shift_count.days)
shift_for(participant, starts_at, limit_end_time(ends_at))
shift_for(participant, [rotation.starts_at, starts_at].max, limit_end_time(ends_at))
end
else
# This is the normal shift start/end times
......
......@@ -146,6 +146,25 @@ RSpec.describe IncidentManagement::OncallShiftGenerator do
[:participant2, '2020-12-20 08:00:00 UTC', '2020-12-20 17:00:00 UTC'],
[:participant2, '2020-12-21 08:00:00 UTC', '2020-12-21 17:00:00 UTC']]
end
context 'rotation start time is in middle of active period' do
before do
rotation.update!(starts_at: rotation_start_time.change(hour: 10))
end
it_behaves_like 'unsaved shifts',
'5 shifts for each participant split by each day',
[[:participant1, '2020-12-08 10:00:00 UTC', '2020-12-08 17:00:00 UTC'],
[:participant1, '2020-12-09 08:00:00 UTC', '2020-12-09 17:00:00 UTC'],
[:participant1, '2020-12-10 08:00:00 UTC', '2020-12-10 17:00:00 UTC'],
[:participant1, '2020-12-11 08:00:00 UTC', '2020-12-11 17:00:00 UTC'],
[:participant1, '2020-12-12 08:00:00 UTC', '2020-12-12 17:00:00 UTC'],
[:participant2, '2020-12-13 08:00:00 UTC', '2020-12-13 17:00:00 UTC'],
[:participant2, '2020-12-14 08:00:00 UTC', '2020-12-14 17:00:00 UTC'],
[:participant2, '2020-12-15 08:00:00 UTC', '2020-12-15 17:00:00 UTC'],
[:participant2, '2020-12-16 08:00:00 UTC', '2020-12-16 17:00:00 UTC'],
[:participant2, '2020-12-17 08:00:00 UTC', '2020-12-17 17:00:00 UTC']]
end
end
context 'when end time is earlier than start time' do
......
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