From 2006f87b580b22c109a3e8cd25b0b5632727532b Mon Sep 17 00:00:00 2001 From: djsegal Date: Fri, 18 Dec 2015 04:05:30 -0500 Subject: [PATCH] Add #3732 helper logic to devise controller: #3864 --- app/controllers/devise_controller.rb | 12 ++++++++---- test/controllers/helper_methods_test.rb | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/controllers/devise_controller.rb b/app/controllers/devise_controller.rb index 3d7cd222..493d5248 100644 --- a/app/controllers/devise_controller.rb +++ b/app/controllers/devise_controller.rb @@ -2,11 +2,15 @@ class DeviseController < Devise.parent_controller.constantize include Devise::Controllers::ScopedViews - helper DeviseHelper + if respond_to?(:helper) + helper DeviseHelper + end - helpers = %w(resource scope_name resource_name signed_in_resource - resource_class resource_params devise_mapping) - helper_method(*helpers) + if respond_to?(:helper_method) + helpers = %w(resource scope_name resource_name signed_in_resource + resource_class resource_params devise_mapping) + helper_method(*helpers) + end prepend_before_action :assert_is_devise_resource! respond_to :html if mimes_for_respond_to.empty? diff --git a/test/controllers/helper_methods_test.rb b/test/controllers/helper_methods_test.rb index 52fa6b88..59f913fd 100644 --- a/test/controllers/helper_methods_test.rb +++ b/test/controllers/helper_methods_test.rb @@ -11,7 +11,8 @@ class HelperMethodsTest < Devise::ControllerTestCase assert_includes @controller.class.ancestors, Devise::Controllers::Helpers end - test 'does not respond_to helper_method' do + test 'does not respond_to helper or helper_method' do + refute_respond_to @controller.class, :helper refute_respond_to @controller.class, :helper_method end