Skip to content
Browse files

Be sure to call helper :all just on direct children. (Tests by Jesse …

…Storimer)
  • Loading branch information...
1 parent 737abf2 commit 625f7b5a5b12df3e7684b1be29c71c1f79a7c7b7 @josevalim josevalim committed
View
1 actionpack/lib/abstract_controller.rb
@@ -2,6 +2,7 @@
$:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path)
require 'action_pack'
+require 'active_support/concern'
require 'active_support/ruby/shim'
require 'active_support/dependencies/autoload'
require 'active_support/core_ext/class/attribute'
View
2 actionpack/lib/action_controller/base.rb
@@ -223,7 +223,7 @@ def self.without_modules(*modules)
def self.inherited(klass)
super
- klass.helper :all
+ klass.helper :all if klass.superclass == ActionController::Base
end
ActiveSupport.run_load_hooks(:action_controller, self)
View
12 actionpack/test/controller/helper_test.rb
@@ -25,6 +25,13 @@ class AllHelpersController < ActionController::Base
helper :all
end
+class JustMeController < ActionController::Base
+ clear_helpers
+end
+
+class MeTooController < JustMeController
+end
+
module LocalAbcHelper
def a() end
def b() end
@@ -92,6 +99,11 @@ def test_helper_for_acronym_controller
# assert_equal 'test: baz', Fun::PdfController.process(request, response).body
end
+ def test_default_helpers_only
+ assert_equal [JustMeHelper], JustMeController._helpers.ancestors.reject(&:anonymous?)
+ assert_equal [MeTooHelper, JustMeHelper], MeTooController._helpers.ancestors.reject(&:anonymous?)
+ end
+
def test_all_helpers
methods = AllHelpersController._helpers.instance_methods.map {|m| m.to_s}
View
3 actionpack/test/fixtures/helpers/just_me_helper.rb
@@ -0,0 +1,3 @@
+module JustMeHelper
+ def me() "mine!" end
+end
View
3 actionpack/test/fixtures/helpers/me_too_helper.rb
@@ -0,0 +1,3 @@
+module MeTooHelper
+ def me() "me too!" end
+end

0 comments on commit 625f7b5

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