A platform for community discussion. Free, open, simple.
FIX: Don’t log an error when rendering a 404
Loïc Guitautbf3d8a0a94e8
diff --git a/app/controllers/list_controller.rb b/app/controllers/list_controller.rbindex cbdb6404604..89e602605eb 100644--- a/app/controllers/list_controller.rb+++ b/app/controllers/list_controller.rb@@ -50,7 +50,7 @@ class ListController < ApplicationController].flattenrescue_from ActionController::Redirecting::UnsafeRedirectError do- raise Discourse::NotFound+ rescue_discourse_actions(:not_found, 404)end# Create our filtersdiff --git a/spec/requests/list_controller_spec.rb b/spec/requests/list_controller_spec.rbindex 69f97f4e73a..4e86f5790a1 100644--- a/spec/requests/list_controller_spec.rb+++ b/spec/requests/list_controller_spec.rb@@ -1227,17 +1227,27 @@ RSpec.describe ListController doendcontext "when redirect raises an unsafe redirect error" do+ let(:fake_logger) { FakeLogger.new }+before doListController.any_instance.stubs(:redirect_to).raises(ActionController::Redirecting::UnsafeRedirectError)+ Rails.logger.broadcast_to(fake_logger)end+ after { Rails.logger.stop_broadcasting_to(fake_logger) }+it "renders a 404" doget "/c/hello/world/bye/#{subsubcategory.id}"expect(response).to have_http_status :not_foundend++ it "doesn’t log an error" do+ get "/c/hello/world/bye/#{subsubcategory.id}"+ expect(fake_logger.fatals).to be_empty+ endendcontext "when provided slug is gibberish" do