From 0fc16551ce18af2c70418bfec2bd90cb1584ec5c Mon Sep 17 00:00:00 2001 From: Jesse Storimer Date: Thu, 26 Aug 2010 22:18:35 -0400 Subject: [PATCH] Ensure that base helper_methods are available after calling clear_helpers --- actionpack/lib/abstract_controller/helpers.rb | 3 +++ actionpack/test/controller/helper_test.rb | 10 ++++++++++ 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/actionpack/lib/abstract_controller/helpers.rb b/actionpack/lib/abstract_controller/helpers.rb index a0ce121..e6de1fa 100644 --- a/actionpack/lib/abstract_controller/helpers.rb +++ b/actionpack/lib/abstract_controller/helpers.rb @@ -98,7 +98,10 @@ module AbstractController # Clears up all existing helpers in this class, only keeping the helper # with the same name as this class. def clear_helpers + base_helper_methods = _helpers.ancestors.last.instance_methods self._helpers = Module.new + + base_helper_methods.each { |m| helper_method m } default_helper_module! unless anonymous? end diff --git a/actionpack/test/controller/helper_test.rb b/actionpack/test/controller/helper_test.rb index 4f8ff41..b5b1965 100644 --- a/actionpack/test/controller/helper_test.rb +++ b/actionpack/test/controller/helper_test.rb @@ -27,6 +27,10 @@ end class JustMeController < ActionController::Base clear_helpers + + def flash + render :inline => "

<%= notice %>

" + end end class MeTooController < JustMeController @@ -104,6 +108,12 @@ class HelperTest < ActiveSupport::TestCase assert_equal [MeTooHelper, JustMeHelper], MeTooController._helpers.ancestors.reject(&:anonymous?) end + def test_base_helper_methods_after_clear_helpers + assert_nothing_raised do + call_controller(JustMeController, "flash") + end + end + def test_all_helpers methods = AllHelpersController._helpers.instance_methods.map {|m| m.to_s} -- 1.7.2.2