Skip to content
Browse files

move `MissingHelperError` out of the `ClassMethods` module.

  • Loading branch information...
1 parent d864dcd commit 5bee14f3a46d6fc907044b739245c74edfb6012b @senny senny committed
Showing with 23 additions and 16 deletions.
  1. +4 −0 actionpack/CHANGELOG.md
  2. +18 −15 actionpack/lib/abstract_controller/helpers.rb
  3. +1 −1 actionpack/test/abstract/helper_test.rb
View
4 actionpack/CHANGELOG.md
@@ -1,3 +1,7 @@
+* Move `MissingHelperError` out of the `ClassMethods` module.
+
+ *Yves Senn*
+
* Fix an issue where rails raise exception about missing helper where it
should throw `LoadError`. When helper file exists and only loaded file from
this helper does not exist rails should throw LoadError instead of
View
33 actionpack/lib/abstract_controller/helpers.rb
@@ -12,7 +12,24 @@ module Helpers
self._helper_methods = Array.new
end
+ class MissingHelperError < LoadError
+ def initialize(error, path)
+ @error = error
+ @path = "helpers/#{path}.rb"
+ set_backtrace error.backtrace
+
+ if error.path =~ /^#{path}(\.rb)?$/
+ super("Missing helper file helpers/%s.rb" % path)
+ else
+ raise error
+ end
+ end
+ end
+
module ClassMethods
+ MissingHelperError = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('AbstractController::Helpers::ClassMethods::MissingHelperError',
+ 'AbstractController::Helpers::MissingHelperError')
+
# When a class is inherited, wrap its helper module in a new module.
# This ensures that the parent class's module can be changed
# independently of the child class's.
@@ -134,7 +151,7 @@ def modules_for_helpers(args)
begin
require_dependency(file_name)
rescue LoadError => e
- raise MissingHelperError.new(e, file_name)
+ raise AbstractController::Helpers::MissingHelperError.new(e, file_name)
end
file_name.camelize.constantize
when Module
@@ -145,20 +162,6 @@ def modules_for_helpers(args)
end
end
- class MissingHelperError < LoadError
- def initialize(error, path)
- @error = error
- @path = "helpers/#{path}.rb"
- set_backtrace error.backtrace
-
- if error.path =~ /^#{path}(\.rb)?$/
- super("Missing helper file helpers/%s.rb" % path)
- else
- raise error
- end
- end
- end
-
private
# Makes all the (instance) methods in the helper module available to templates
# rendered through this controller.
View
2 actionpack/test/abstract/helper_test.rb
@@ -113,7 +113,7 @@ def test_controller_raise_error_about_real_require_problem
end
def test_controller_raise_error_about_missing_helper
- e = assert_raise(Helpers::ClassMethods::MissingHelperError) { AbstractInvalidHelpers.helper(:missing) }
+ e = assert_raise(AbstractController::Helpers::MissingHelperError) { AbstractInvalidHelpers.helper(:missing) }
assert_equal "Missing helper file helpers/missing_helper.rb", e.message
end
end

0 comments on commit 5bee14f

Please sign in to comment.
Something went wrong with that request. Please try again.