Respond with not found on missing tenants

Just like we respond with "not found" for any other record. This
improves the user experience because with the "Not found" error message
people realize the URL is wrong instead of thinking that they broke the
application.
This commit is contained in:
Javi Martín
2022-12-03 14:53:07 +01:00
parent 159a24f452
commit 94f78c0a55
2 changed files with 9 additions and 0 deletions

View File

@@ -48,6 +48,7 @@ module Consul
# Handle custom exceptions # Handle custom exceptions
config.action_dispatch.rescue_responses["FeatureFlags::FeatureDisabled"] = :forbidden config.action_dispatch.rescue_responses["FeatureFlags::FeatureDisabled"] = :forbidden
config.action_dispatch.rescue_responses["Apartment::TenantNotFound"] = :not_found
# Store uploaded files on the local file system (see config/storage.yml for options). # Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local config.active_storage.service = :local

View File

@@ -173,4 +173,12 @@ describe "Multitenancy", :seed_tenants do
expect(page).not_to have_css "html.tenant-public" expect(page).not_to have_css "html.tenant-public"
end end
end end
scenario "Shows the not found page when accessing a non-existing tenant", :show_exceptions do
with_subdomain("jupiter") do
visit root_path
expect(page).to have_title "Not found"
end
end
end end