diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-07 11:10:46 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-07 11:10:46 +0000 |
commit | a544d7aa372a080b77940571a3a169496045670e (patch) | |
tree | 1d4bfe7d3c28d896fe1c879fdc12c661e14cc8aa /actionpack/test | |
parent | 94921293dbdbdf7fe49023fe7ed8908e05d3615f (diff) | |
download | rails-a544d7aa372a080b77940571a3a169496045670e.tar.gz rails-a544d7aa372a080b77940571a3a169496045670e.tar.bz2 rails-a544d7aa372a080b77940571a3a169496045670e.zip |
Added all the HTTP methods as alternatives to the generic "process" for functional testing #276 [Tobias Luetke]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@58 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/action_pack_assertions_test.rb | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb index 6d727be5a2..489373d5c3 100644 --- a/actionpack/test/controller/action_pack_assertions_test.rb +++ b/actionpack/test/controller/action_pack_assertions_test.rb @@ -54,6 +54,18 @@ class ActionPackAssertionsController < ActionController::Base session['xmas'] = 'turkey' render_text "ho ho ho" end + + # raises exception on get requests + def raise_on_get + raise "get" if @request.get? + render_text "request method: #{@request.env['REQUEST_METHOD']}" + end + + # raises exception on post requests + def raise_on_post + raise "post" if @request.post? + render_text "request method: #{@request.env['REQUEST_METHOD']}" + end # 911 def rescue_action(e) raise; end @@ -70,7 +82,7 @@ ActionPackAssertionsController.template_root = File.dirname(__FILE__) + "/../fix # a test case to exercise the new capabilities TestRequest & TestResponse -class ActionPackAssertionsControllerTest < Test::Unit::TestCase +class ActionPackAssertionsControllerTest < Test::Unit::TestCase # let's get this party started def setup @controller = ActionPackAssertionsController.new @@ -85,6 +97,20 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase assert_session_has 'xmas' assert_session_has_no 'halloween' end + + # test the get method, make sure the request really was a get + def test_get + assert_raise(RuntimeError) { get :raise_on_get } + get :raise_on_post + assert_equal @response.body, 'request method: GET' + end + + # test the get method, make sure the request really was a get + def test_post + assert_raise(RuntimeError) { post :raise_on_post } + post :raise_on_get + assert_equal @response.body, 'request method: POST' + end # test the assertion of goodies in the template def test_assert_template_has |