aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/action_pack_assertions_test.rb28
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