[Catalyst-commits] r11785 - in Catalyst-Runtime/5.80/branches/basic-app-ctx-separation: lib/Catalyst t

zby at dev.catalyst.perl.org zby at dev.catalyst.perl.org
Sun Nov 8 11:50:17 GMT 2009


Author: zby
Date: 2009-11-08 11:50:16 +0000 (Sun, 08 Nov 2009)
New Revision: 11785

Modified:
   Catalyst-Runtime/5.80/branches/basic-app-ctx-separation/lib/Catalyst/Dispatcher.pm
   Catalyst-Runtime/5.80/branches/basic-app-ctx-separation/lib/Catalyst/Test.pm
   Catalyst-Runtime/5.80/branches/basic-app-ctx-separation/t/unit_core_uri_for.t
   Catalyst-Runtime/5.80/branches/basic-app-ctx-separation/t/unit_load_catalyst_test.t
Log:
a few more tests passing

Modified: Catalyst-Runtime/5.80/branches/basic-app-ctx-separation/lib/Catalyst/Dispatcher.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/basic-app-ctx-separation/lib/Catalyst/Dispatcher.pm	2009-11-07 23:45:08 UTC (rev 11784)
+++ Catalyst-Runtime/5.80/branches/basic-app-ctx-separation/lib/Catalyst/Dispatcher.pm	2009-11-08 11:50:16 UTC (rev 11785)
@@ -312,6 +312,19 @@
     if( $component_or_class eq blessed($c->application) ){
         my $possible_action = $c->application->action_for($method);
         return $possible_action if $possible_action;
+        if( my $code = $c->application->can($method) ){
+            return $self->_method_action_class->new(
+                {
+                    name      => $method,
+                    code      => $code,
+                    reverse   => "$component_or_class->$method",
+                    class     => $component_or_class,
+                    namespace => Catalyst::Utils::class2prefix(
+                        $component_or_class, $c->config->{case_sensitive}
+                    ),
+                }
+            );
+        }
     }
     my $component = $self->_find_component($c, $component_or_class);
     my $component_class = blessed $component || return 0;

Modified: Catalyst-Runtime/5.80/branches/basic-app-ctx-separation/lib/Catalyst/Test.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/basic-app-ctx-separation/lib/Catalyst/Test.pm	2009-11-07 23:45:08 UTC (rev 11784)
+++ Catalyst-Runtime/5.80/branches/basic-app-ctx-separation/lib/Catalyst/Test.pm	2009-11-08 11:50:16 UTC (rev 11785)
@@ -51,8 +51,11 @@
 
         my $meta = Class::MOP::get_metaclass_by_name($class);
         $meta->make_mutable;
-        $meta->add_after_method_modifier( "dispatch", sub {
-            $c = shift;
+        $meta->add_around_method_modifier( "prepare", sub {
+                my $orig = shift;
+                my $self = shift;
+
+                $c = $self->$orig(@_);
         });
         $meta->make_immutable( replace_constructor => 1 );
         Class::C3::reinitialize(); # Fixes RT#46459, I've failed to write a test for how/why, but it does.

Modified: Catalyst-Runtime/5.80/branches/basic-app-ctx-separation/t/unit_core_uri_for.t
===================================================================
--- Catalyst-Runtime/5.80/branches/basic-app-ctx-separation/t/unit_core_uri_for.t	2009-11-07 23:45:08 UTC (rev 11784)
+++ Catalyst-Runtime/5.80/branches/basic-app-ctx-separation/t/unit_core_uri_for.t	2009-11-08 11:50:16 UTC (rev 11785)
@@ -10,67 +10,65 @@
                 base => URI->new('http://127.0.0.1/foo')
               } );
 
-my $context = Catalyst->new( {
-                context => Catalyst::Context->new( request => $request, namespace => 'yada' ),
-              } );
+my $context = Catalyst::Context->new( request => $request, namespace => 'yada', application => Catalyst->new() );
 
 is(
-    Catalyst::uri_for( $context, '/bar/baz' )->as_string,
+    Catalyst::Context::uri_for( $context, '/bar/baz' )->as_string,
     'http://127.0.0.1/foo/bar/baz',
     'URI for absolute path'
 );
 
 is(
-    Catalyst::uri_for( $context, 'bar/baz' )->as_string,
+    Catalyst::Context::uri_for( $context, 'bar/baz' )->as_string,
     'http://127.0.0.1/foo/yada/bar/baz',
     'URI for relative path'
 );
 
 is(
-    Catalyst::uri_for( $context, '', 'arg1', 'arg2' )->as_string,
+    Catalyst::Context::uri_for( $context, '', 'arg1', 'arg2' )->as_string,
     'http://127.0.0.1/foo/yada/arg1/arg2',
     'URI for undef action with args'
 );
 
 
-is( Catalyst::uri_for( $context, '../quux' )->as_string,
+is( Catalyst::Context::uri_for( $context, '../quux' )->as_string,
     'http://127.0.0.1/foo/quux', 'URI for relative dot path' );
 
 is(
-    Catalyst::uri_for( $context, 'quux', { param1 => 'value1' } )->as_string,
+    Catalyst::Context::uri_for( $context, 'quux', { param1 => 'value1' } )->as_string,
     'http://127.0.0.1/foo/yada/quux?param1=value1',
     'URI for undef action with query params'
 );
 
-is (Catalyst::uri_for( $context, '/bar/wibble?' )->as_string,
+is (Catalyst::Context::uri_for( $context, '/bar/wibble?' )->as_string,
    'http://127.0.0.1/foo/bar/wibble%3F', 'Question Mark gets encoded'
 );
    
-is( Catalyst::uri_for( $context, qw/bar wibble?/, 'with space' )->as_string,
+is( Catalyst::Context::uri_for( $context, qw/bar wibble?/, 'with space' )->as_string,
     'http://127.0.0.1/foo/yada/bar/wibble%3F/with%20space', 'Space gets encoded'
 );
 
 is(
-    Catalyst::uri_for( $context, '/bar', 'with+plus', { 'also' => 'with+plus' })->as_string,
+    Catalyst::Context::uri_for( $context, '/bar', 'with+plus', { 'also' => 'with+plus' })->as_string,
     'http://127.0.0.1/foo/bar/with+plus?also=with%2Bplus',
     'Plus is not encoded'
 );
 
 # test with utf-8
 is(
-    Catalyst::uri_for( $context, 'quux', { param1 => "\x{2620}" } )->as_string,
+    Catalyst::Context::uri_for( $context, 'quux', { param1 => "\x{2620}" } )->as_string,
     'http://127.0.0.1/foo/yada/quux?param1=%E2%98%A0',
     'URI for undef action with query params in unicode'
 );
 is(
-    Catalyst::uri_for( $context, 'quux', { 'param:1' => "foo" } )->as_string,
+    Catalyst::Context::uri_for( $context, 'quux', { 'param:1' => "foo" } )->as_string,
     'http://127.0.0.1/foo/yada/quux?param%3A1=foo',
     'URI for undef action with query params in unicode'
 );
 
 # test with object
 is(
-    Catalyst::uri_for( $context, 'quux', { param1 => $request->base } )->as_string,
+    Catalyst::Context::uri_for( $context, 'quux', { param1 => $request->base } )->as_string,
     'http://127.0.0.1/foo/yada/quux?param1=http%3A%2F%2F127.0.0.1%2Ffoo',
     'URI for undef action with query param as object'
 );
@@ -78,7 +76,7 @@
 $request->base( URI->new('http://localhost:3000/') );
 $request->match( 'orderentry/contract' );
 is(
-    Catalyst::uri_for( $context, '/Orderentry/saveContract' )->as_string,
+    Catalyst::Context::uri_for( $context, '/Orderentry/saveContract' )->as_string,
     'http://localhost:3000/Orderentry/saveContract',
     'URI for absolute path'
 );
@@ -88,11 +86,11 @@
 
     $context->namespace('');
 
-    is( Catalyst::uri_for( $context, '/bar/baz' )->as_string,
+    is( Catalyst::Context::uri_for( $context, '/bar/baz' )->as_string,
         'http://127.0.0.1/bar/baz', 'URI with no base or match' );
 
     # test "0" as the path
-    is( Catalyst::uri_for( $context, qw/0 foo/ )->as_string,
+    is( Catalyst::Context::uri_for( $context, qw/0 foo/ )->as_string,
         'http://127.0.0.1/0/foo', '0 as path is ok'
     );
 
@@ -103,12 +101,12 @@
     my $warnings = 0;
     local $SIG{__WARN__} = sub { $warnings++ };
 
-    Catalyst::uri_for( $context, '/bar/baz', { foo => undef } )->as_string,
+    Catalyst::Context::uri_for( $context, '/bar/baz', { foo => undef } )->as_string,
     is( $warnings, 0, "no warnings emitted" );
 }
 
 # Test with parameters '/', 'foo', 'bar' - should not generate a //
-is( Catalyst::uri_for( $context, qw| / foo bar | )->as_string,
+is( Catalyst::Context::uri_for( $context, qw| / foo bar | )->as_string,
     'http://127.0.0.1/foo/bar', 'uri is /foo/bar, not //foo/bar'
 );
 
@@ -118,7 +116,7 @@
     # according to the RFC, but it is a very big feature change so I've removed it
     no warnings; # Yes, everything in qw is sane
     is(
-        Catalyst::uri_for( $context, qw|! * ' ( ) ; : @ & = $ / ? % # [ ] ,|, )->as_string,
+        Catalyst::Context::uri_for( $context, qw|! * ' ( ) ; : @ & = $ / ? % # [ ] ,|, )->as_string,
         'http://127.0.0.1/%21/%2A/%27/%2B/%29/%3B/%3A/%40/%26/%3D/%24/%2C/%2F/%3F/%25/%23/%5B/%5D',
         'rfc 3986 reserved characters'
     );
@@ -126,7 +124,7 @@
     # jshirley bug - why the hell does only one of these get encoded
     #                has been like this forever however.
     is(
-        Catalyst::uri_for( $context, qw|{1} {2}| )->as_string,
+        Catalyst::Context::uri_for( $context, qw|{1} {2}| )->as_string,
         'http://127.0.0.1/{1}/{2}',
         'not-escaping unreserved characters'
     );
@@ -138,7 +136,7 @@
                              bar  => ["foo baz", "bar"]};
     my $query_params_test = {test => "one two",
                              bar  => ["foo baz", "bar"]};
-    Catalyst::uri_for($context, '/bar/baz', $query_params_test);
+    Catalyst::Context::uri_for($context, '/bar/baz', $query_params_test);
     is_deeply($query_params_base, $query_params_test,
               "uri_for() doesn't mess up query parameter hash in the caller");
 }

Modified: Catalyst-Runtime/5.80/branches/basic-app-ctx-separation/t/unit_load_catalyst_test.t
===================================================================
--- Catalyst-Runtime/5.80/branches/basic-app-ctx-separation/t/unit_load_catalyst_test.t	2009-11-07 23:45:08 UTC (rev 11784)
+++ Catalyst-Runtime/5.80/branches/basic-app-ctx-separation/t/unit_load_catalyst_test.t	2009-11-08 11:50:16 UTC (rev 11785)
@@ -82,7 +82,7 @@
         skip "Context tests skipped for '$meth'", 6 unless $meth eq 'ctx_request';
 
         ok( $c,                 "           Context object returned" );
-        isa_ok( $c, $App,       "               Object" );
+        isa_ok( $c, $App->context_class,       "               Object" );
         is( $c->request->uri, $Url,
                                 "               Url recorded in request" );
         is( $c->response->body, $Content,




More information about the Catalyst-commits mailing list