Fix Heartbeat Test Runs before 9am UTC#1139
Conversation
Greptile SummaryThis PR fixes a flaky test that failed when run before 9am UTC. The Confidence Score: 5/5Safe to merge — test-only change with a correct, targeted fix for a timing-dependent flake. No production code is changed. The fix correctly pins time to noon UTC using the standard Rails travel_to helper, ensuring heartbeats at 9am UTC always fall within the daily_streaks_for_users query window (start_date..Time.current). No P0 or P1 issues found. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Test runs at real clock time T] --> B{Is T before 9am UTC?}
B -- Yes --> C[beginning_of_day + 9h is a future timestamp]
C --> D[daily_streaks_for_users filters time up to Time.current]
D --> E[Heartbeat excluded from query window]
E --> F[streak = 0 — assertion fails]
B -- No --> G[beginning_of_day + 9h is a past timestamp]
G --> H[Heartbeat included in query window]
H --> I[streak = 1 — test passes]
J[Fix: travel_to noon UTC] --> G
Reviews (1): Last reviewed commit: "fix: heatrbeat test 9am issue" | Re-trigger Greptile |
ts should make the tests for #1138 pass