From bdf7d11c94f371499f13e9009177f9faac1f9a37 Mon Sep 17 00:00:00 2001 From: zzak Date: Mon, 29 May 2023 14:23:26 +0900 Subject: [PATCH] Import ActionController::MissingRenderer from Rails --- lib/action_controller/responder.rb | 7 +++++++ test/action_controller/respond_with_test.rb | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/action_controller/responder.rb b/lib/action_controller/responder.rb index 5c77ba9..ab28263 100644 --- a/lib/action_controller/responder.rb +++ b/lib/action_controller/responder.rb @@ -131,6 +131,13 @@ class Responder put: :edit } + # See Responder#api_behavior + class MissingRenderer < LoadError + def initialize(format) + super "No renderer defined for format: #{format}" + end + end + def initialize(controller, resources, options = {}) @controller = controller @request = @controller.request diff --git a/test/action_controller/respond_with_test.rb b/test/action_controller/respond_with_test.rb index 2daf625..eb6628b 100644 --- a/test/action_controller/respond_with_test.rb +++ b/test/action_controller/respond_with_test.rb @@ -723,7 +723,7 @@ def test_using_resource_with_set_responder def test_raises_missing_renderer_if_an_api_behavior_with_no_renderer @controller = CsvRespondWithController.new - assert_raise ActionController::MissingRenderer do + assert_raise ActionController::Responder::MissingRenderer do get :index, format: "csv" end end