Merge pull request #47199 from skipkayhil/deprecate-missing-helper-error

Deprecate AbstractController MissingHelperError
This commit is contained in:
Eileen M. Uchitelle 2023-01-31 08:48:29 -05:00 committed by GitHub
commit 77d4ce0ade
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 1 deletions

View File

@ -1,3 +1,7 @@
* Deprecate `AbstractController::Helpers::MissingHelperError`
*Hartley McGuire*
* Change `ActionDispatch::Testing::TestResponse#parsed_body` to parse HTML as
a Nokogiri document

View File

@ -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

View File

@ -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

View File

@ -52,6 +52,8 @@ Please refer to the [Changelog][action-pack] for detailed changes.
### Deprecations
* Deprecate `AbstractController::Helpers::MissingHelperError`
* Deprecate `ActionDispatch::IllegalStateError`.
### Notable changes