Back compat fix for CX::CRUD and others
Tomas Doran [Sun, 7 Aug 2011 12:14:01 +0000 (13:14 +0100)]
Changes
TODO
lib/Catalyst/Test.pm
t/aggregate/unit_load_catalyst_test.t

diff --git a/Changes b/Changes
index 6d84521..35028a9 100644 (file)
--- a/Changes
+++ b/Changes
 
   - Fix calling MyApp->engine_class to set the engine class manually.
 
+  - Re-add a $res->headers->{status} field to Catalyst::Test responses.
+    This _should_ be accessed with $c->res->code instead, but is here
+    for backward compatibility.
+
  Documentation:
 
   - Documentation which was in the now removed Catalyst::Engine::* classes
diff --git a/TODO b/TODO
index 2a856bb..9d718ea 100644 (file)
--- a/TODO
+++ b/TODO
@@ -53,8 +53,6 @@ http://github.com/willert/catalyst-plugin-log4perl-simple/tree
 
   * Test::WWW::Mechanize::Catalyst new release
 
-  * CatalystX::CRUD 0.51 is broken, but works against latest master.
-
   * Test nginx middleware to determine if it is needed with:
 
     root app - with use_request_uri_for_path
index ef3def5..5c0cbe7 100644 (file)
@@ -311,6 +311,10 @@ sub _local_request {
             for my $f ( $h->header_field_names ) {
                 $resp->init_header( $f, [ $h->header($f) ] );
             }
+            # Another horrible hack to make the response headers have a
+            # 'status' field. This is for back-compat, but you should
+            # call $resp->code instead!
+            $resp->init_header('status', [ $resp->code ]);
         },
     }, @_);
 }
index 399b190..68dfbdf 100644 (file)
@@ -153,4 +153,8 @@ lives_ok {
     request(GET('/dummy'), []);
 } 'array additional param to request method ignored';
 
+my $res = request(GET('/'));
+is $res->code, 200, 'Response code 200';
+is $res->headers->{status}, 200, 'Back compat "status" header present';
+
 done_testing;