From 4db54e183639a56ea125c9da9f1817f22f0ac54c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20V=C3=A1squez?= Date: Tue, 21 Jul 2026 07:31:32 -0600 Subject: [PATCH 1/2] Fix flaky madmin projects index spec The spec asserted the raw project title appears in the rendered page, but the title is HTML-escaped (e.g. an apostrophe becomes '), so it failed intermittently whenever Faker generated a company name with special characters. Compare against the HTML-escaped title instead. --- spec/requests/madmin/projects_spec.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/requests/madmin/projects_spec.rb b/spec/requests/madmin/projects_spec.rb index 23b9e782..391f8dcd 100644 --- a/spec/requests/madmin/projects_spec.rb +++ b/spec/requests/madmin/projects_spec.rb @@ -13,7 +13,10 @@ get "/madmin/projects" expect(response).to have_http_status(:ok) - expect(response.body).to include(project.title) + # The title is HTML-escaped in the rendered page (e.g. an apostrophe + # becomes '), so compare against the escaped form to avoid a flaky + # failure whenever Faker generates a name with special characters. + expect(response.body).to include(CGI.escapeHTML(project.title)) end end From 936b3d6a2ee4a03f3f577f15a17a8b0f401ed66e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20V=C3=A1squez?= Date: Tue, 21 Jul 2026 09:26:56 -0600 Subject: [PATCH 2/2] Load routes before suite so Devise mappings resolve on Rails 8.1 Rails 8.1 loads routes lazily. Devise registers its scope mappings while the routes are drawn (devise_for), so before the routes load Devise.mappings is empty and every controller-spec sign_in raises 'Could not find a valid mapping'. Force the routes to load in a before(:suite) hook, which fixes the build-rails-next lane and is harmless on Rails 8.0. --- spec/rails_helper.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index c93a2b0c..0a289ff2 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -132,6 +132,14 @@ def executor_around_each_request # arbitrary gems may also be filtered via: # config.filter_gems_from_backtrace("gem name") + # Rails 8.1 loads routes lazily. Devise registers its mappings while the + # routes are drawn (via devise_for), so until the routes are loaded + # Devise.mappings is empty and sign_in raises "Could not find a valid + # mapping". Force the routes to load before the suite runs. + config.before(:suite) do + Rails.application.reload_routes_unless_loaded + end + config.before(:suite) do DatabaseCleaner.clean_with(:truncation) end