diff --git a/config/routes.rb b/config/routes.rb index 867980bc1..261491519 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,4 @@ +# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html Rails.application.routes.draw do devise_for :admin_users, { path: :admin, @@ -28,12 +29,10 @@ Rails.application.routes.draw do get "/health", to: ->(_) { [204, {}, [nil]] } - # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html ActiveAdmin.routes(self) root to: "start#index" - # Content pages get "/accessibility-statement", to: "content#accessibility_statement" get "/privacy-notice", to: "content#privacy_notice" diff --git a/spec/config/routes_spec.rb b/spec/config/routes_spec.rb new file mode 100644 index 000000000..e5f0505f4 --- /dev/null +++ b/spec/config/routes_spec.rb @@ -0,0 +1,23 @@ +require "rails_helper" + +RSpec.describe "routes.rb" do + let(:all_routes) do + Rails.application.routes.routes.map { |r| r.path.spec.to_s if r.defaults[:controller] }.compact + end + let(:active_admin_routes_prefix) { "/admin" } + let(:rails_routes_prefix) { "/rails" } + let(:turbo_routes_pattern) { "_historical_location" } + let(:project_routes) do + all_routes.reject do |r| + r.starts_with?(active_admin_routes_prefix) || r.starts_with?(rails_routes_prefix) || + r.include?(turbo_routes_pattern) + end + end + + it "does not use underscores" do + routes_with_underscores = project_routes.select do |r| + r.split("/").any? { |component| !component.start_with?(":") && component.match("_") } + end + expect(routes_with_underscores).to be_empty + end +end