From 120a2f70a9ea3b08a39fc1fbb251f59ecf968cde Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Thu, 29 Feb 2024 11:54:36 +1000 Subject: [PATCH] DEV: Fix hot topic flaky spec (#25948) It's February 29th, you know what that means...date-based flaky specs! If today is February 29th 2024: ``` freeze_time(1.year.ago) -> Tue, 28 Feb 2023 01:38:42.732875000 UTC +00:00 ``` Then ``` freeze_time(1.year.from_now) -> Wed, 28 Feb 2024 01:38:42.732875000 UTC +00:00 ``` So then our "now" for the insert query ends up being "yesterday" ``` WHERE topic_hot_scores.topic_id IS NULL AND topics.deleted_at IS NULL AND topics.archetype <> :private_message AND topics.created_at <= :now ``` --- spec/models/topic_hot_scores_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/models/topic_hot_scores_spec.rb b/spec/models/topic_hot_scores_spec.rb index 836315b1223..2c9bacb89e9 100644 --- a/spec/models/topic_hot_scores_spec.rb +++ b/spec/models/topic_hot_scores_spec.rb @@ -29,7 +29,8 @@ RSpec.describe TopicHotScore do end it "can correctly update like counts and post counts and account for activity" do - freeze_time + # freeze to specific date + time to avoid flakiness from leap years + freeze_time(DateTime.parse("2024-02-01 01:00")) TopicHotScore.create!(topic_id: -1, score: 0.0, recent_likes: 99, recent_posters: 0)