Skip to content

Commit

Permalink
Deprecate AbstractController MissingHelperError
Browse files Browse the repository at this point in the history
This error used to be a wrapper for a LoadError raised when
require_dependency was used to load helpers for controllers.

Since Zeitwerk does not use require_dependency, the only usage of the
error was removed in 5b28a0e.
  • Loading branch information
skipkayhil committed Jan 31, 2023
1 parent c819075 commit ada584b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions actionpack/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Deprecate `AbstractController::Helpers::MissingHelperError`

*Hartley McGuire*

* Change `ActionDispatch::Testing::TestResponse#parsed_body` to parse HTML as
a Nokogiri document

Expand Down
6 changes: 5 additions & 1 deletion actionpack/lib/abstract_controller/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

module AbstractController
module Helpers
include ActiveSupport::Deprecation::DeprecatedConstantAccessor
extend ActiveSupport::Concern

included do
Expand All @@ -23,7 +24,7 @@ module Helpers
self._helpers = define_helpers_module(self)
end

class MissingHelperError < LoadError
class DeprecatedMissingHelperError < LoadError
def initialize(error, path)
@error = error
@path = "helpers/#{path}.rb"
Expand All @@ -36,6 +37,9 @@ def initialize(error, path)
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
Expand Down
6 changes: 6 additions & 0 deletions actionpack/test/controller/helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ def test_helper_proxy_config
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
Expand Down
2 changes: 2 additions & 0 deletions guides/source/7_1_release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Please refer to the [Changelog][action-pack] for detailed changes.

### Deprecations

* Deprecate `AbstractController::Helpers::MissingHelperError`

* Deprecate `ActionDispatch::IllegalStateError`.

### Notable changes
Expand Down

0 comments on commit ada584b

Please sign in to comment.