diff --git a/ee/spec/factories/incident_management/oncall_shifts.rb b/ee/spec/factories/incident_management/oncall_shifts.rb
index a0282cc2f684f97332710aaca89c70e21861c047..eb80fbd87ad2f7fab0bcea132917242c3c47b939 100644
--- a/ee/spec/factories/incident_management/oncall_shifts.rb
+++ b/ee/spec/factories/incident_management/oncall_shifts.rb
@@ -4,7 +4,7 @@
   factory :incident_management_oncall_shift, class: 'IncidentManagement::OncallShift' do
     association :participant, :with_developer_access, factory: :incident_management_oncall_participant
     rotation { participant.rotation }
-    starts_at { 5.days.ago }
-    ends_at { 2.days.from_now }
+    starts_at { rotation.starts_at }
+    ends_at { starts_at + rotation.shift_duration }
   end
 end