From 615fd99f9fafa3e32b6fca691373e742739bb18f Mon Sep 17 00:00:00 2001 From: Morgan Roderick Date: Thu, 16 Apr 2026 09:39:13 +0200 Subject: [PATCH] fix(test): wrap flaky homepage tests in travel_to blocks Fix time-dependent flaky tests by wrapping scenarios in travel_to blocks. The issue was that fabricator timestamps are evaluated at file load time, while the upcoming scope compares against Time.zone.now at query time. When time passes between fixture creation and page visit, events may be filtered out incorrectly. This follows the same pattern as commit 3f44835e which fixed similar flaky tests in other files. --- spec/features/visiting_homepage_spec.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/spec/features/visiting_homepage_spec.rb b/spec/features/visiting_homepage_spec.rb index 8148da7f1..27d0590c6 100644 --- a/spec/features/visiting_homepage_spec.rb +++ b/spec/features/visiting_homepage_spec.rb @@ -2,7 +2,7 @@ let!(:next_workshop) { Fabricate(:workshop) } let!(:events) { Fabricate.times(3, :event) } - before(:each) do + before do visit root_path end @@ -11,11 +11,15 @@ end scenario 'i can view the next workshop' do - expect(page).to have_content "Workshop at #{next_workshop.host.name}" + travel_to(Time.current) do + expect(page).to have_content "Workshop at #{next_workshop.host.name}" + end end scenario 'i can view the next 5 upcoming events' do - events.take(5).each { |event| expect(page).to have_content "#{event.name} at #{event.venue.name}" } + travel_to(Time.current) do + events.take(5).each { |event| expect(page).to have_content "#{event.name} at #{event.venue.name}" } + end end scenario 'i can access the code of conduct' do @@ -37,7 +41,7 @@ end inactive_chapters.each do |chapter| - expect(page).to_not have_content(chapter.name) + expect(page).not_to have_content(chapter.name) end end