From 4761fdc30749d417378084cd72adaf581933a2db Mon Sep 17 00:00:00 2001 From: Lance Ivy Date: Sun, 17 Aug 2008 18:32:53 -0700 Subject: [PATCH] add TestResponse#client_error? to check for 4xx status codes --- actionpack/lib/action_controller/test_process.rb | 5 +++++ .../test/controller/action_pack_assertions_test.rb | 6 ++++++ 2 files changed, 11 insertions(+), 0 deletions(-) diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb index 0c70520..fb4cfac 100644 --- a/actionpack/lib/action_controller/test_process.rb +++ b/actionpack/lib/action_controller/test_process.rb @@ -187,6 +187,11 @@ module ActionController #:nodoc: (300..399).include?(response_code) end + # Was this a bad request? + def client_error? + (400..499).include?(response_code) + end + # Was there a server-side error? def error? (500..599).include?(response_code) diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb index 56ba36c..7559937 100644 --- a/actionpack/test/controller/action_pack_assertions_test.rb +++ b/actionpack/test/controller/action_pack_assertions_test.rb @@ -368,6 +368,12 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase assert @response.missing? end + # check a client error response code + def test_client_error_response_code + process :response404 + assert @response.client_error? + end + # check to see if our redirection matches a pattern def test_redirect_url_match process :redirect_external -- 1.5.4.3