diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-05-02 02:15:09 -0700 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-05-02 02:15:09 -0700 |
commit | 72160d9f89481ea60c8268ff026099f07b1e5ed6 (patch) | |
tree | 950b7516323658c7012e3ca742b7bd9930a83aa7 /actionpack/test | |
parent | ad2a1b5cb1afb0ea810cfdcac2ba1be95c55f1aa (diff) | |
download | rails-72160d9f89481ea60c8268ff026099f07b1e5ed6.tar.gz rails-72160d9f89481ea60c8268ff026099f07b1e5ed6.tar.bz2 rails-72160d9f89481ea60c8268ff026099f07b1e5ed6.zip |
Implement FooController.action(:name)
* Rails actions are now Rack endpoints, and can be retrieved
via FooController.action(name) and called with an env
* Updated some tests that relied on the old internal
#process/#call implementation
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/filters_test.rb | 3 | ||||
-rw-r--r-- | actionpack/test/controller/helper_test.rb | 40 | ||||
-rw-r--r-- | actionpack/test/new_base/test_helper.rb | 2 |
3 files changed, 31 insertions, 14 deletions
diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index 9e74538310..3b113131ae 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -602,8 +602,9 @@ class FilterTest < Test::Unit::TestCase def test_dynamic_dispatch %w(foo bar baz).each do |action| request = ActionController::TestRequest.new + request.env["action_controller.rescue.request"] = request request.query_parameters[:choose] = action - response = DynamicDispatchController.process(request, ActionController::TestResponse.new) + response = DynamicDispatchController.action.call(request.env).last assert_equal action, response.body end end diff --git a/actionpack/test/controller/helper_test.rb b/actionpack/test/controller/helper_test.rb index 58addc123d..19cd5f4db2 100644 --- a/actionpack/test/controller/helper_test.rb +++ b/actionpack/test/controller/helper_test.rb @@ -101,20 +101,30 @@ class HelperTest < Test::Unit::TestCase assert master_helper_methods.include?('delegate_attr=') end - def test_helper_for_nested_controller + def call_controller(klass, action) request = ActionController::TestRequest.new - response = ActionController::TestResponse.new - request.action = 'render_hello_world' + request.env["action_controller.rescue.request"] = request + klass.action(action).call(request.env) + end - assert_equal 'hello: Iz guuut!', Fun::GamesController.process(request, response).body + def test_helper_for_nested_controller + assert_equal 'hello: Iz guuut!', + call_controller(Fun::GamesController, "render_hello_world").last.body + # request = ActionController::TestRequest.new + # request.env["action_controller.rescue.request"] = request + # + # resp = Fun::GamesController.action(:render_hello_world).call(request.env) + # assert_equal 'hello: Iz guuut!', resp.last.body end def test_helper_for_acronym_controller - request = ActionController::TestRequest.new - response = ActionController::TestResponse.new - request.action = 'test' - - assert_equal 'test: baz', Fun::PdfController.process(request, response).body + assert_equal "test: baz", call_controller(Fun::PdfController, "test").last.body + # + # request = ActionController::TestRequest.new + # response = ActionController::TestResponse.new + # request.action = 'test' + # + # assert_equal 'test: baz', Fun::PdfController.process(request, response).body end def test_all_helpers @@ -204,6 +214,12 @@ class IsolatedHelpersTest < Test::Unit::TestCase end end + def call_controller(klass, action) + request = ActionController::TestRequest.new + request.env["action_controller.rescue.request"] = request + klass.action(action).call(request.env) + end + def setup @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new @@ -211,14 +227,14 @@ class IsolatedHelpersTest < Test::Unit::TestCase end def test_helper_in_a - assert_raise(ActionView::TemplateError) { A.process(@request, @response) } + assert_raise(ActionView::TemplateError) { call_controller(A, "index") } end def test_helper_in_b - assert_equal 'B', B.process(@request, @response).body + assert_equal 'B', call_controller(B, "index").last.body end def test_helper_in_c - assert_equal 'C', C.process(@request, @response).body + assert_equal 'C', call_controller(C, "index").last.body end end diff --git a/actionpack/test/new_base/test_helper.rb b/actionpack/test/new_base/test_helper.rb index 547eb1ef72..78662dc989 100644 --- a/actionpack/test/new_base/test_helper.rb +++ b/actionpack/test/new_base/test_helper.rb @@ -66,7 +66,7 @@ class Rack::TestCase < ActiveSupport::TestCase end def assert_body(body) - assert_equal body, last_response.body + assert_equal body, Array.wrap(last_response.body).join end def self.assert_body(body) |