diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 0214466c51e..93ed7dd1828 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,3 +1,7 @@ +* Deprecate `AbstractController::Helpers::MissingHelperError` + + *Hartley McGuire* + * Change `ActionDispatch::Testing::TestResponse#parsed_body` to parse HTML as a Nokogiri document diff --git a/actionpack/lib/abstract_controller/helpers.rb b/actionpack/lib/abstract_controller/helpers.rb index eb4f7c8c9bf..4cf4adf5981 100644 --- a/actionpack/lib/abstract_controller/helpers.rb +++ b/actionpack/lib/abstract_controller/helpers.rb @@ -5,6 +5,7 @@ require "active_support/core_ext/name_error" module AbstractController module Helpers + include ActiveSupport::Deprecation::DeprecatedConstantAccessor extend ActiveSupport::Concern included do @@ -23,7 +24,7 @@ module AbstractController self._helpers = define_helpers_module(self) end - class MissingHelperError < LoadError + class DeprecatedMissingHelperError < LoadError def initialize(error, path) @error = error @path = "helpers/#{path}.rb" @@ -36,6 +37,9 @@ module AbstractController end end end + deprecate_constant "MissingHelperError", "AbstractController::Helpers::DeprecatedMissingHelperError", + message: "AbstractController::Helpers::MissingHelperError has been deprecated. If a Helper is not present, a NameError will be raised instead.", + deprecator: AbstractController.deprecator def _helpers self.class._helpers diff --git a/actionpack/test/controller/helper_test.rb b/actionpack/test/controller/helper_test.rb index f1bfb8436c2..7b904e0c818 100644 --- a/actionpack/test/controller/helper_test.rb +++ b/actionpack/test/controller/helper_test.rb @@ -264,6 +264,12 @@ class HelperTest < ActiveSupport::TestCase assert_equal "smth", AllHelpersController.helpers.config.my_var end + def test_missing_helper_error_is_deprecated + assert_deprecated(AbstractController.deprecator) do + AbstractController::Helpers::MissingHelperError + end + end + private def expected_helper_methods TestHelper.instance_methods diff --git a/guides/source/7_1_release_notes.md b/guides/source/7_1_release_notes.md index ed05f95bb8a..d0d9aeaa5cf 100644 --- a/guides/source/7_1_release_notes.md +++ b/guides/source/7_1_release_notes.md @@ -52,6 +52,8 @@ Please refer to the [Changelog][action-pack] for detailed changes. ### Deprecations +* Deprecate `AbstractController::Helpers::MissingHelperError` + * Deprecate `ActionDispatch::IllegalStateError`. ### Notable changes