Skip to content

Commit

Permalink
AO3-6911: prefer lazy loaded locale, fix route
Browse files Browse the repository at this point in the history
  • Loading branch information
boyer-victor committed Feb 24, 2025
1 parent 3f2d882 commit 69978a8
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def raise_not_found
rescue_from Rack::Timeout::RequestTimeoutException, with: :raise_timeout

def raise_timeout
redirect_to "/timeout"
redirect_to timeout_error_path
end

helper :all # include all helpers, all the time
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/errors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ class ErrorsController < ApplicationController
end

def auth_error
@page_subtitle = "Auth Error"
@page_subtitle = t(".subtitle")
end

def timeout_error
@page_subtitle = "Timeout Error"
@page_subtitle = t(".subtitle")
end
end
3 changes: 0 additions & 3 deletions app/views/errors/timeout.html.erb

This file was deleted.

3 changes: 3 additions & 0 deletions app/views/errors/timeout_error.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h2 class="heading"><%= t(".title") %></h2>
<h3 class="heading"><%= t(".subtitle") %></h3>
<p><%= t(".html", contact_support_link: link_to(t(".contact_support"), new_feedback_report_path)) %></p>

Check failure on line 3 in app/views/errors/timeout_error.html.erb

View workflow job for this annotation

GitHub Actions / ERB Lint runner

[] reported by reviewdog 🐶 Missing a trailing newline at the end of the file. Raw Output: app/views/errors/timeout_error.html.erb:3:104: Missing a trailing newline at the end of the file.
5 changes: 5 additions & 0 deletions config/locales/controllers/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ en:
error: Sorry, that comment could not be unhidden.
permission_denied: Sorry, you don't have permission to unhide that comment.
success: Comment successfully unhidden!
errors:
timeout:
subtitle: "Timeout Error"
auth:
subtitle: "Authentication Error"
external_works:
update:
successfully_updated: External work was successfully updated.
Expand Down
2 changes: 1 addition & 1 deletion config/locales/views/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ en:
revealed_html: A translation of %{work_link} by %{creator_link}
unrevealed: A translation of a work in an unrevealed collection
errors:
timeout:
timeout_error:
title: Timeout
subtitle: The page was responding too slowly. Please try again after a few minutes.
html: If you still get this error after a few tries, please %{contact_support_link}.
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
get '/422', to: 'errors#422'
get '/500', to: 'errors#500'
get '/auth_error', to: 'errors#auth_error'
get "/timeout", to: "errors#timeout"
get "/timeout_error", to: "errors#timeout_error"

#### DOWNLOADS ####

Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/errors_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
end
end

describe "auth_error" do
describe "GET #auth_error" do
it "returns an HTML auth error page" do
get :auth_error
expect(response.status).to eq(200)
Expand Down

0 comments on commit 69978a8

Please sign in to comment.