diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2007-02-24 20:31:34 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2007-02-24 20:31:34 +0000 |
commit | f95dfff966696cba237723e4abfefd3ae8ca91cb (patch) | |
tree | 8bfb23afa40836bfd1526b725cd54b058169452a /actionpack/test | |
parent | 351eea1fcd9619472165859534f655870518023d (diff) | |
download | rails-f95dfff966696cba237723e4abfefd3ae8ca91cb.tar.gz rails-f95dfff966696cba237723e4abfefd3ae8ca91cb.tar.bz2 rails-f95dfff966696cba237723e4abfefd3ae8ca91cb.zip |
Added helper(:all) as a way to include all helpers from app/helpers/**/*.rb in ApplicationController [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6221 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/helper_test.rb | 21 | ||||
-rw-r--r-- | actionpack/test/fixtures/helpers/fun/pdf_helper.rb | 2 |
2 files changed, 20 insertions, 3 deletions
diff --git a/actionpack/test/controller/helper_test.rb b/actionpack/test/controller/helper_test.rb index 98c8f7e72c..54e2582ca2 100644 --- a/actionpack/test/controller/helper_test.rb +++ b/actionpack/test/controller/helper_test.rb @@ -1,5 +1,7 @@ require File.dirname(__FILE__) + '/../abstract_unit' +silence_warnings { ActionController::Helpers::HELPERS_DIR = File.dirname(__FILE__) + '/../fixtures/helpers' } + class TestController < ActionController::Base attr_accessor :delegate_attr def delegate_method() end @@ -15,7 +17,7 @@ module Fun def rescue_action(e) raise end end - class PDFController < ActionController::Base + class PdfController < ActionController::Base def test render :inline => "test: <%= foobar %>" end @@ -24,6 +26,10 @@ module Fun end end +class ApplicationController < ActionController::Base + helper :all +end + module LocalAbcHelper def a() end def b() end @@ -120,7 +126,18 @@ class HelperTest < Test::Unit::TestCase response = ActionController::TestResponse.new request.action = 'test' - assert_equal 'test: baz', Fun::PDFController.process(request, response).body + assert_equal 'test: baz', Fun::PdfController.process(request, response).body + end + + def test_all_helpers + # abc_helper.rb + assert ApplicationController.master_helper_module.instance_methods.include?("bare_a") + + # fun/games_helper.rb + assert ApplicationController.master_helper_module.instance_methods.include?("stratego") + + # fun/pdf_helper.rb + assert ApplicationController.master_helper_module.instance_methods.include?("foobar") end private diff --git a/actionpack/test/fixtures/helpers/fun/pdf_helper.rb b/actionpack/test/fixtures/helpers/fun/pdf_helper.rb index 1890f6c9ec..c4aea5a3f3 100644 --- a/actionpack/test/fixtures/helpers/fun/pdf_helper.rb +++ b/actionpack/test/fixtures/helpers/fun/pdf_helper.rb @@ -1,3 +1,3 @@ -module Fun::PDFHelper +module Fun::PdfHelper def foobar() 'baz' end end |