From 6001cea5d70344d4c13b5cff94ee853f5f5462ce Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Tue, 3 Mar 2009 16:42:20 -0800 Subject: Helpers with an initial test --- .../abstract_controller_test.rb | 21 +----------- .../test/abstract_controller/callbacks_test.rb | 22 +----------- actionpack/test/abstract_controller/helper_test.rb | 39 ++++++++++++++++++++++ actionpack/test/abstract_controller/test_helper.rb | 22 ++++++++++++ .../test/abstract_controller/views/helper_test.erb | 1 + 5 files changed, 64 insertions(+), 41 deletions(-) create mode 100644 actionpack/test/abstract_controller/helper_test.rb create mode 100644 actionpack/test/abstract_controller/test_helper.rb create mode 100644 actionpack/test/abstract_controller/views/helper_test.erb (limited to 'actionpack/test/abstract_controller') diff --git a/actionpack/test/abstract_controller/abstract_controller_test.rb b/actionpack/test/abstract_controller/abstract_controller_test.rb index 4834f8b7bb..7b0caa3837 100644 --- a/actionpack/test/abstract_controller/abstract_controller_test.rb +++ b/actionpack/test/abstract_controller/abstract_controller_test.rb @@ -1,23 +1,4 @@ -$:.unshift(File.dirname(__FILE__) + '/../../lib') -$:.unshift(File.dirname(__FILE__) + '/../../../activesupport/lib') - -require 'test/unit' -require 'active_support' -require 'active_support/test_case' -require 'action_controller' -require 'action_view/base' - -begin - require 'ruby-debug' - Debugger.settings[:autoeval] = true - Debugger.start -rescue LoadError - # Debugging disabled. `gem install ruby-debug` to enable. -end - -require 'action_controller/abstract/base' -require 'action_controller/abstract/renderer' -require 'action_controller/abstract/layouts' +require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") module AbstractController module Testing diff --git a/actionpack/test/abstract_controller/callbacks_test.rb b/actionpack/test/abstract_controller/callbacks_test.rb index 2657a31ca9..89243b631e 100644 --- a/actionpack/test/abstract_controller/callbacks_test.rb +++ b/actionpack/test/abstract_controller/callbacks_test.rb @@ -1,24 +1,4 @@ -$:.unshift(File.dirname(__FILE__) + '/../../lib') -$:.unshift(File.dirname(__FILE__) + '/../../../activesupport/lib') - -require 'test/unit' -require 'active_support' -require 'active_support/test_case' -require 'action_controller' -require 'action_view/base' - -begin - require 'ruby-debug' - Debugger.settings[:autoeval] = true - Debugger.start -rescue LoadError - # Debugging disabled. `gem install ruby-debug` to enable. -end - -require 'action_controller/abstract/base' -require 'action_controller/abstract/renderer' -require 'action_controller/abstract/layouts' -require 'action_controller/abstract/callbacks' +require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") module AbstractController module Testing diff --git a/actionpack/test/abstract_controller/helper_test.rb b/actionpack/test/abstract_controller/helper_test.rb new file mode 100644 index 0000000000..81dbee3065 --- /dev/null +++ b/actionpack/test/abstract_controller/helper_test.rb @@ -0,0 +1,39 @@ +require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") + +module AbstractController + module Testing + + class ControllerWithHelpers < AbstractController::Base + include Renderer + include Helpers + + append_view_path File.expand_path(File.join(File.dirname(__FILE__), "views")) + end + + module HelperyTest + def included_method + "Included" + end + end + + class MyHelpers1 < ControllerWithHelpers + helper(HelperyTest) do + def helpery_test + "World" + end + end + + def index + render "helper_test.erb" + end + end + + class TestHelpers < ActiveSupport::TestCase + def test_helpers + result = MyHelpers1.process(:index) + assert_equal "Hello World : Included", result.response_obj[:body] + end + end + + end +end \ No newline at end of file diff --git a/actionpack/test/abstract_controller/test_helper.rb b/actionpack/test/abstract_controller/test_helper.rb new file mode 100644 index 0000000000..9f94baea35 --- /dev/null +++ b/actionpack/test/abstract_controller/test_helper.rb @@ -0,0 +1,22 @@ +$:.unshift(File.dirname(__FILE__) + '/../../lib') +$:.unshift(File.dirname(__FILE__) + '/../../../activesupport/lib') + +require 'test/unit' +require 'active_support' +require 'active_support/test_case' +require 'action_controller' +require 'action_view/base' + +begin + require 'ruby-debug' + Debugger.settings[:autoeval] = true + Debugger.start +rescue LoadError + # Debugging disabled. `gem install ruby-debug` to enable. +end + +require 'action_controller/abstract/base' +require 'action_controller/abstract/renderer' +require 'action_controller/abstract/layouts' +require 'action_controller/abstract/callbacks' +require 'action_controller/abstract/helpers' \ No newline at end of file diff --git a/actionpack/test/abstract_controller/views/helper_test.erb b/actionpack/test/abstract_controller/views/helper_test.erb new file mode 100644 index 0000000000..8ae45cc195 --- /dev/null +++ b/actionpack/test/abstract_controller/views/helper_test.erb @@ -0,0 +1 @@ +Hello <%= helpery_test %> : <%= included_method %> \ No newline at end of file -- cgit v1.2.3