[Catalyst-commits] r9393 - in Catalyst-Runtime/5.80/branches/deprecate_req_user: lib/Catalyst t t/lib/DeprecatedTestApp/C

dwc at dev.catalyst.perl.org dwc at dev.catalyst.perl.org
Tue Feb 24 18:01:51 GMT 2009


Author: dwc
Date: 2009-02-24 18:01:51 +0000 (Tue, 24 Feb 2009)
New Revision: 9393

Modified:
   Catalyst-Runtime/5.80/branches/deprecate_req_user/lib/Catalyst/Request.pm
   Catalyst-Runtime/5.80/branches/deprecate_req_user/t/deprecated.t
   Catalyst-Runtime/5.80/branches/deprecate_req_user/t/lib/DeprecatedTestApp/C/Root.pm
Log:
Add (currently failing) test for deprecated ->req->user warning. The warning should only be triggered in the app, not from the engines

Modified: Catalyst-Runtime/5.80/branches/deprecate_req_user/lib/Catalyst/Request.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/deprecate_req_user/lib/Catalyst/Request.pm	2009-02-24 17:07:54 UTC (rev 9392)
+++ Catalyst-Runtime/5.80/branches/deprecate_req_user/lib/Catalyst/Request.pm	2009-02-24 18:01:51 UTC (rev 9393)
@@ -135,7 +135,7 @@
             'You probably meant to call $c->user or $c->req->remote_user'
         );
         $self->_user_deprecated_has_warned(1);
-     }
+    }
 };
 
 sub args            { shift->arguments(@_) }

Modified: Catalyst-Runtime/5.80/branches/deprecate_req_user/t/deprecated.t
===================================================================
--- Catalyst-Runtime/5.80/branches/deprecate_req_user/t/deprecated.t	2009-02-24 17:07:54 UTC (rev 9392)
+++ Catalyst-Runtime/5.80/branches/deprecate_req_user/t/deprecated.t	2009-02-24 18:01:51 UTC (rev 9393)
@@ -4,7 +4,7 @@
 use warnings;
 use FindBin qw/$Bin/;
 use lib "$Bin/lib";
-use Test::More tests => 4;
+use Test::More tests => 6;
 use Test::MockObject;
 
 my $warnings;
@@ -13,10 +13,13 @@
     $SIG{__WARN__} = sub { $warnings++ if $_[0] =~ /trying to use NEXT/ };
 }
 use Catalyst; # Cause catalyst to be used so I can fiddle with the logging.
-my $mvc_warnings;
+my ($mvc_warnings, $req_user_warnings);
 BEGIN {
     my $logger = Test::MockObject->new;
-    $logger->mock('warn', sub { $mvc_warnings++ if $_[1] =~ /switch your class names/ });
+    $logger->mock('warn', sub {
+        $mvc_warnings++ if $_[1] =~ /switch your class names/;
+        $req_user_warnings++ if $_[1] =~ /Attempt to use \$c->req->user; this is deprecated/;
+    });
     Catalyst->log($logger);
 }
 
@@ -30,3 +33,11 @@
     skip 'non-dev release', 1 unless Catalyst::_IS_DEVELOPMENT_VERSION();
     is( $warnings, 1, 'Got one and only one Adopt::NEXT warning');
 }
+
+# Test that we warn about use of deprecated $c->req->user
+{
+    local $ENV{REMOTE_USER} = 'dwc';
+
+    ok( request('http://localhost/req_user'), 'Request' );
+    is( $req_user_warnings, 1, 'Got a warning for using $c->req->user' );
+}

Modified: Catalyst-Runtime/5.80/branches/deprecate_req_user/t/lib/DeprecatedTestApp/C/Root.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/deprecate_req_user/t/lib/DeprecatedTestApp/C/Root.pm	2009-02-24 17:07:54 UTC (rev 9392)
+++ Catalyst-Runtime/5.80/branches/deprecate_req_user/t/lib/DeprecatedTestApp/C/Root.pm	2009-02-24 18:01:51 UTC (rev 9393)
@@ -10,4 +10,9 @@
     $c->res->body('root index');
 }
 
+sub req_user : Local {
+    my ( $self, $c ) = @_;
+    $c->res->body('REMOTE_USER = ' . $c->req->user);
+}
+
 1;




More information about the Catalyst-commits mailing list