From b5a17d7648116532805c86d4fe16770da1e616f4 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Mon, 13 Sep 2010 12:51:42 -0700 Subject: [PATCH] Allow view helper's #initialize method to be called. [#5061 state:resolved] --- actionpack/lib/action_view/test_case.rb | 6 +++++- actionpack/test/template/test_case_test.rb | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb index e9d2e0b843020..2c2661df267d9 100644 --- a/actionpack/lib/action_view/test_case.rb +++ b/actionpack/lib/action_view/test_case.rb @@ -74,6 +74,11 @@ def helper_class @helper_class ||= determine_default_helper_class(name) end + def new(*) + include_helper_modules! + super + end + private def include_helper_modules! @@ -89,7 +94,6 @@ def setup_with_controller @output_buffer = ActiveSupport::SafeBuffer.new @rendered = '' - self.class.send(:include_helper_modules!) make_test_case_available_to_view! say_no_to_protect_against_forgery! end diff --git a/actionpack/test/template/test_case_test.rb b/actionpack/test/template/test_case_test.rb index a0c46f8a594f8..878a5f05f9995 100644 --- a/actionpack/test/template/test_case_test.rb +++ b/actionpack/test/template/test_case_test.rb @@ -253,4 +253,17 @@ class RenderTemplateTest < ActionView::TestCase end end end + + module AHelperWithInitialize + def initialize(*) + super + @called_initialize = true + end + end + + class AHelperWithInitializeTest < ActionView::TestCase + test "the helper's initialize was actually called" do + assert @called_initialize + end + end end