diff --git a/app/controllers/error_controller.rb b/app/controllers/error_controller.rb index 491dccc971..abdf11f264 100644 --- a/app/controllers/error_controller.rb +++ b/app/controllers/error_controller.rb @@ -2,8 +2,12 @@ class ErrorController < ApplicationController skip_before_action :authenticate_user! + skip_after_action :verify_authorized def index + end + + def create raise StandardError.new "This is an intentional test exception" end end diff --git a/app/views/error/index.html.erb b/app/views/error/index.html.erb index 13254f3cae..769a97ca15 100644 --- a/app/views/error/index.html.erb +++ b/app/views/error/index.html.erb @@ -1,6 +1,7 @@
-

We're sorry, but something went wrong.

-

If you are the application owner check the logs for more information.

+

Intentional Error Test

+

Click the button below to trigger an intentional test exception.

+ <%= button_to "Trigger Exception", error_path, method: :post, class: "btn btn-danger", data: { turbo: false } %>
diff --git a/config/routes.rb b/config/routes.rb index 9a353356f1..83b6d8f374 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -241,6 +241,7 @@ end get "/error", to: "error#index" + post "/error", to: "error#create" namespace :api do namespace :v1 do diff --git a/spec/requests/error_spec.rb b/spec/requests/error_spec.rb index 0362a0aa87..65e91b0c95 100644 --- a/spec/requests/error_spec.rb +++ b/spec/requests/error_spec.rb @@ -1,9 +1,19 @@ require "rails_helper" RSpec.describe "/error", type: :request do - it "raises an error causing an internal server error" do - expect { + describe "GET /error" do + it "renders the error test page" do get error_path - }.to raise_error(StandardError, /This is an intentional test exception/) + + expect(response).to be_successful + end + end + + describe "POST /error" do + it "raises an error causing an internal server error" do + expect { + post error_path + }.to raise_error(StandardError, /This is an intentional test exception/) + end end end