From 17906172fa3fb1bc090e6b8339beca3626f0ad28 Mon Sep 17 00:00:00 2001 From: maebeale Date: Tue, 4 Aug 2026 09:12:32 -0400 Subject: [PATCH] Stop #joinable? join-window specs racing the wall clock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The join-window boundary examples place events exactly 1 minute inside the 30-minute buffer, so they depended on wall-clock drift between factory-build and assertion staying under a minute — thin enough to spike under CI load. Freeze the clock across the describe so they're deterministic. Also add a global travel_back after each example: RSpec never runs minitest teardown, so a frozen clock would otherwise leak into later specs. Co-Authored-By: Claude Opus 4.8 (1M context) --- spec/models/event_registration_spec.rb | 4 ++++ spec/rails_helper.rb | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/spec/models/event_registration_spec.rb b/spec/models/event_registration_spec.rb index 8a37cc56f5..ec364e1cd8 100644 --- a/spec/models/event_registration_spec.rb +++ b/spec/models/event_registration_spec.rb @@ -535,6 +535,10 @@ def registration_with_scholarship end describe "#joinable?" do + # Freeze the clock so the join-window boundary cases (events placed exactly + # 1 minute inside the 30-minute buffer) can't flake on wall-clock drift. + before { freeze_time } + let(:event) { create(:event, cost_cents: 1099, start_date: 1.hour.ago, end_date: 1.hour.from_now) } let(:user) { create(:user, :with_person) } diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 3c5a4e6834..962224f3db 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -48,6 +48,10 @@ RSpec.configure do |config| # Gives travel method for time helpers config.include ActiveSupport::Testing::TimeHelpers + # RSpec doesn't run minitest teardown, so travel_to never auto-reverts — freeze + # one example and the frozen clock leaks into later specs. Always reset after + # each example (no-op when time wasn't traveled). + config.after { travel_back } # Include pagination helper globally config.include PaginationHelpers