aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/abstract_controller
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2019-05-27 15:35:08 -0700
committerJohn Hawthorn <john@hawthorn.email>2019-06-03 18:59:51 -0700
commit17424a7de15694432405f56f97424d50b2e908b5 (patch)
tree0bb8d9751dcd137c531b951315dabefe4fdbd6e6 /actionpack/lib/abstract_controller
parentc926ca46280aee795b98206dd0707a96b9423cc5 (diff)
downloadrails-17424a7de15694432405f56f97424d50b2e908b5.tar.gz
rails-17424a7de15694432405f56f97424d50b2e908b5.tar.bz2
rails-17424a7de15694432405f56f97424d50b2e908b5.zip
Give HelperMethods module a name
Diffstat (limited to 'actionpack/lib/abstract_controller')
-rw-r--r--actionpack/lib/abstract_controller/helpers.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/actionpack/lib/abstract_controller/helpers.rb b/actionpack/lib/abstract_controller/helpers.rb
index 3913259ecc..8ff214f220 100644
--- a/actionpack/lib/abstract_controller/helpers.rb
+++ b/actionpack/lib/abstract_controller/helpers.rb
@@ -7,7 +7,7 @@ module AbstractController
extend ActiveSupport::Concern
included do
- class_attribute :_helpers, default: Module.new
+ class_attribute :_helpers, default: define_helpers_module(self)
class_attribute :_helper_methods, default: Array.new
end
@@ -31,7 +31,7 @@ module AbstractController
# independently of the child class's.
def inherited(klass)
helpers = _helpers
- klass._helpers = Module.new { include helpers }
+ klass._helpers = define_helpers_module(klass, helpers)
klass.class_eval { default_helper_module! } unless klass.anonymous?
super
end
@@ -170,6 +170,17 @@ module AbstractController
end
private
+ def define_helpers_module(klass, helpers = nil)
+ # In some tests inherited is called explicitly. In that case, just
+ # return the module from the first time it was defined
+ return klass.const_get(:HelperMethods) if klass.const_defined?(:HelperMethods, false)
+
+ mod = Module.new
+ klass.const_set(:HelperMethods, mod)
+ mod.include(helpers) if helpers
+ mod
+ end
+
# Makes all the (instance) methods in the helper module available to templates
# rendered through this controller.
#