From d2a48032c5ad0e62593fdafddb315dd28c701e29 Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Sat, 20 Jun 2015 23:45:29 -0500 Subject: [PATCH] Remove unused controller rescue_from handler Per https://github.com/rails-api/active_model_serializers/pull/954#discussion_r32589882 Ref 917, 918 --- lib/action_controller/serialization.rb | 19 ------------- test/action_controller/rescue_from_test.rb | 32 ---------------------- 2 files changed, 51 deletions(-) delete mode 100644 test/action_controller/rescue_from_test.rb diff --git a/lib/action_controller/serialization.rb b/lib/action_controller/serialization.rb index e9b474660..abb17fe36 100644 --- a/lib/action_controller/serialization.rb +++ b/lib/action_controller/serialization.rb @@ -48,25 +48,6 @@ def use_adapter? end end - # Tries to rescue the exception by looking up and calling a registered handler. - # - # Possibly Deprecated - # TODO: Either Decorate 'exception' and define #handle_error where it is serialized - # For example: - # class ExceptionModel - # include ActiveModel::Serialization - # def initialize(exception) - # # etc - # end - # def handle_error(exception) - # exception_model = ActiveModel::Serializer.build_exception_model({ errors: ['Internal Server Error'] }) - # render json: exception_model, status: :internal_server_error - # end - # OR remove method as it doesn't do anything right now. - def rescue_with_handler(exception) - super(exception) - end - module ClassMethods def serialization_scope(scope) self._serialization_scope = scope diff --git a/test/action_controller/rescue_from_test.rb b/test/action_controller/rescue_from_test.rb deleted file mode 100644 index d4231c3be..000000000 --- a/test/action_controller/rescue_from_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'test_helper' - -module ActionController - module Serialization - class RescueFromTest < ActionController::TestCase - class RescueFromTestController < ActionController::Base - rescue_from Exception, with: :handle_error - - def render_using_raise_error_serializer - profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' }) - render json: [profile], serializer: RaiseErrorSerializer - end - - def handle_error(exception) - render json: { errors: ['Internal Server Error'] }, status: :internal_server_error - end - end - - tests RescueFromTestController - - def test_rescue_from - get :render_using_raise_error_serializer - - expected = { - errors: ['Internal Server Error'] - }.to_json - - assert_equal expected, response.body - end - end - end -end