From: Marcus Ramberg Date: Thu, 3 Nov 2005 07:46:04 +0000 (+0000) Subject: test inheritance of builtin actions in mainapp. X-Git-Tag: 5.7099_04~1040 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=01ba879fae4d3ac2babde66ec6d45b822ba412f8;hp=57e4592849c4ec6ba7a0dea780ce8b2aa2de5606;p=catagits%2FCatalyst-Runtime.git test inheritance of builtin actions in mainapp. --- diff --git a/META.yml b/META.yml index b7c62e0..3bcb12b 100644 --- a/META.yml +++ b/META.yml @@ -1,6 +1,6 @@ --- name: Catalyst -version: 5.49_01 +version: 5.49_02 author: - 'Sebastian Riedel, C' abstract: The Elegant MVC Web Application Framework @@ -15,6 +15,7 @@ requires: HTTP::Request: 0 HTTP::Response: 0 LWP::UserAgent: 0 + MIME::Types: 0 Module::Pluggable::Fast: 0.16 NEXT: 0 Path::Class: 0.09 @@ -26,20 +27,31 @@ requires: Tree::Simple::Visitor::FindByPath: 0 UNIVERSAL::require: 0 URI: 1.35 - URI::Query: 0 perl: 5.8.1 recommends: Catalyst::Engine::Apache: 0 provides: Catalyst: file: lib/Catalyst.pm - version: 5.49_01 + version: 5.49_02 Catalyst::Action: file: lib/Catalyst/Action.pm + Catalyst::ActionContainer: + file: lib/Catalyst/ActionContainer.pm Catalyst::Base: file: lib/Catalyst/Base.pm Catalyst::Build: file: lib/Catalyst/Build.pm + Catalyst::DispatchType: + file: lib/Catalyst/DispatchType.pm + Catalyst::DispatchType::Default: + file: lib/Catalyst/DispatchType/Default.pm + Catalyst::DispatchType::Index: + file: lib/Catalyst/DispatchType/Index.pm + Catalyst::DispatchType::Path: + file: lib/Catalyst/DispatchType/Path.pm + Catalyst::DispatchType::Regex: + file: lib/Catalyst/DispatchType/Regex.pm Catalyst::Dispatcher: file: lib/Catalyst/Dispatcher.pm Catalyst::Engine: @@ -61,6 +73,9 @@ provides: version: 0.01 Catalyst::Log: file: lib/Catalyst/Log.pm + Catalyst::Plugin::Static::Simple: + file: lib/Catalyst/Plugin/Static/Simple.pm + version: 0.11 Catalyst::Request: file: lib/Catalyst/Request.pm Catalyst::Request::Upload: @@ -71,4 +86,4 @@ provides: file: lib/Catalyst/Test.pm Catalyst::Utils: file: lib/Catalyst/Utils.pm -generated_by: Module::Build version 0.2611 +generated_by: Module::Build version 0.2607 diff --git a/README b/README index 8ead33a..669f8bf 100644 --- a/README +++ b/README @@ -52,7 +52,7 @@ DESCRIPTION use Catalyst 'My::Module'; - Special flags like -Debug and -Engine can also be specifed as arguments + Special flags like -Debug and -Engine can also be specified as arguments when Catalyst is loaded: use Catalyst qw/-Debug My::Module/; @@ -88,6 +88,9 @@ DESCRIPTION Specify log level. METHODS + $c->action + Accessor for the current action + $c->comp($name) $c->component($name) Get a component object by name. @@ -118,15 +121,27 @@ METHODS $c->forward(qw/MyApp::Model::CDBI::Foo do_stuff/); $c->forward('MyApp::View::TT'); + $c->namespace + Accessor to the namespace of the current action + + $c->path_to(@path) + Merges @path with $c->config->{home} and returns a Path::Class + object. + + For example: + + $c->path_to( 'db', 'sqlite.db' ); + $c->setup Setup. $c->setup; - $c->uri_for($path) + $c->uri_for($path,[@args]) Merges path with $c->request->base for absolute uri's and with $c->request->match for relative uri's, then returns a normalized URI - object. + object. If any args are passed, they are added at the end of the + path. $c->error $c->error($error, ...) @@ -139,6 +154,10 @@ METHODS $c->error('Something bad happened'); + Clean errors. + + $c->error(0); + $c->engine Contains the engine instance. Stringifies to the class. @@ -178,9 +197,21 @@ METHODS $c->stash Returns a hashref containing all your data. - $c->stash->{foo} ||= 'yada'; print $c->stash->{foo}; + Keys may be set in the stash by assigning to the hash reference, or + by passing either a single hash reference or a list of key/value + pairs as arguments. + + For example: + + $c->stash->{foo} ||= 'yada'; + $c->stash( { moose => 'majestic', qux => 0 } ); + $c->stash( bar => 1, gorch => 2 ); + + $c->welcome_message + Returns the Catalyst welcome HTML page. + INTERNAL METHODS $c->benchmark($coderef) Takes a coderef with arguments and returns elapsed time as float. @@ -245,6 +276,9 @@ INTERNAL METHODS $c->prepare_body Prepare message body. + $c->prepare_body_chunk( $chunk ) + Prepare a chunk of data before sending it to HTTP::Body. + $c->prepare_body_parameters Prepare body parameters. @@ -308,6 +342,10 @@ INTERNAL METHODS you will need to manually set the Content-Length header to the length of your output data, if known. + version + Returns the Catalyst version number. mostly useful for powered by + messages in template systems. + CASE SENSITIVITY By default Catalyst is not case sensitive, so "MyApp::C::FOO::Bar" becomes "/foo/bar". @@ -393,6 +431,10 @@ CREDITS Andy Wardley + Andreas Marienborg + + Andrew Bramble + Andrew Ford Andrew Ruthven @@ -437,10 +479,12 @@ CREDITS Ulf Edvinsson + Yuval Kogman + AUTHOR Sebastian Riedel, "sri@oook.de" LICENSE - This library is free software . You can redistribute it and/or modify it - under the same terms as perl itself. + This library is free software, you can redistribute it and/or modify it + under the same terms as Perl itself. diff --git a/t/live/component/controller/action/auto.t b/t/live/component/controller/action/auto.t index acc3ca7..f99d4ad 100644 --- a/t/live/component/controller/action/auto.t +++ b/t/live/component/controller/action/auto.t @@ -35,6 +35,7 @@ sub run_tests { TestApp::Controller::Action::Auto->begin TestApp::Controller::Action::Auto->auto TestApp::Controller::Action::Auto->one + TestApp->end ]; my $expected = join( ", ", @expected ); @@ -51,6 +52,7 @@ sub run_tests { TestApp::Controller::Action::Auto->begin TestApp::Controller::Action::Auto->auto TestApp::Controller::Action::Auto->default + TestApp->end ]; my $expected = join( ", ", @expected ); @@ -68,6 +70,7 @@ sub run_tests { TestApp::Controller::Action::Auto->auto TestApp::Controller::Action::Auto::Deep->auto TestApp::Controller::Action::Auto::Deep->one + TestApp->end ]; my $expected = join( ", ", @expected ); @@ -85,6 +88,7 @@ sub run_tests { TestApp::Controller::Action::Auto->auto TestApp::Controller::Action::Auto::Deep->auto TestApp::Controller::Action::Auto::Deep->default + TestApp->end ]; my $expected = join( ", ", @expected ); diff --git a/t/live/component/controller/action/begin.t b/t/live/component/controller/action/begin.t index 66f764c..ab65643 100644 --- a/t/live/component/controller/action/begin.t +++ b/t/live/component/controller/action/begin.t @@ -30,6 +30,7 @@ sub run_tests { TestApp::Controller::Action::Begin->begin TestApp::Controller::Action::Begin->default TestApp::View::Dump::Request->process + TestApp->end ]; my $expected = join( ", ", @expected ); diff --git a/t/live/component/controller/action/default.t b/t/live/component/controller/action/default.t index e5c0614..2e1d68b 100644 --- a/t/live/component/controller/action/default.t +++ b/t/live/component/controller/action/default.t @@ -29,6 +29,7 @@ sub run_tests { TestApp::Controller::Action::Default->begin TestApp::Controller::Action::Default->default TestApp::View::Dump::Request->process + TestApp->end ]; my $expected = join( ", ", @expected ); diff --git a/t/live/component/controller/action/detach.t b/t/live/component/controller/action/detach.t index a9712ad..adc5c8e 100644 --- a/t/live/component/controller/action/detach.t +++ b/t/live/component/controller/action/detach.t @@ -30,6 +30,7 @@ sub run_tests { TestApp::Controller::Action::Detach->one TestApp::Controller::Action::Detach->two TestApp::View::Dump::Request->process + TestApp->end ]; my $expected = join( ", ", @expected ); @@ -56,6 +57,7 @@ sub run_tests { TestApp::Controller::Action::Detach->path TestApp::Controller::Action::Detach->two TestApp::View::Dump::Request->process + TestApp->end ]; my $expected = join( ", ", @expected ); diff --git a/t/live/component/controller/action/forward.t b/t/live/component/controller/action/forward.t index b57d568..d64b5f9 100644 --- a/t/live/component/controller/action/forward.t +++ b/t/live/component/controller/action/forward.t @@ -33,6 +33,7 @@ sub run_tests { TestApp::Controller::Action::Forward->four TestApp::Controller::Action::Forward->five TestApp::View::Dump::Request->process + TestApp->end ]; my $expected = join( ", ", @expected ); @@ -80,6 +81,7 @@ sub run_tests { TestApp::Controller::Action::Forward->four TestApp::Controller::Action::Forward->five TestApp::View::Dump::Request->process + TestApp->end ]; my $expected = join( ", ", @expected ); diff --git a/t/live/component/controller/action/index.t b/t/live/component/controller/action/index.t index 6be00f0..cd4f9b0 100644 --- a/t/live/component/controller/action/index.t +++ b/t/live/component/controller/action/index.t @@ -10,7 +10,7 @@ our $iters; BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; } -use Test::More tests => 19*$iters; +use Test::More tests => 20*$iters; use Catalyst::Test 'TestApp'; if ( $ENV{CAT_BENCHMARK} ) { @@ -26,7 +26,15 @@ else { sub run_tests { # test root index { + my @expected = qw[ + TestApp->index + TestApp->end + ]; + + my $expected = join( ", ", @expected ); ok( my $response = request('http://localhost/'), 'root index' ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); is( $response->content, 'root index', 'root index ok' ); ok( $response = request('http://localhost'), 'root index no slash' ); @@ -37,6 +45,7 @@ sub run_tests { { my @expected = qw[ TestApp::Controller::Index->index + TestApp->end ]; my $expected = join( ", ", @expected ); @@ -57,6 +66,7 @@ sub run_tests { my @expected = qw[ TestApp::Controller::Action::Index->begin TestApp::Controller::Action::Index->index + TestApp->end ]; my $expected = join( ", ", @expected ); @@ -77,6 +87,7 @@ sub run_tests { my @expected = qw[ TestApp::Controller::Action::Index->begin TestApp::Controller::Action::Index->default + TestApp->end ]; my $expected = join( ", ", @expected ); diff --git a/t/live/lib/Catalyst/Plugin/Test/Plugin.pm b/t/live/lib/Catalyst/Plugin/Test/Plugin.pm index 0fdf99d..62b2cad 100644 --- a/t/live/lib/Catalyst/Plugin/Test/Plugin.pm +++ b/t/live/lib/Catalyst/Plugin/Test/Plugin.pm @@ -2,7 +2,7 @@ package Catalyst::Plugin::Test::Plugin; use strict; -use base 'Class::Data::Inheritable'; +use base qw/Catalyst::Base Class::Data::Inheritable/; __PACKAGE__->mk_classdata('ran_setup'); @@ -22,4 +22,8 @@ sub prepare { } +sub end : Private { + my ($self,$c) = @_; +} + 1; diff --git a/t/live/lib/TestApp.pm b/t/live/lib/TestApp.pm index 974e9f3..4ab30c3 100644 --- a/t/live/lib/TestApp.pm +++ b/t/live/lib/TestApp.pm @@ -20,6 +20,7 @@ sub global_action : Private { $c->forward('TestApp::View::Dump::Request'); } + sub execute { my $c = shift; my $class = ref( $c->component( $_[0] ) ) || $_[0]; @@ -33,6 +34,10 @@ sub execute { elsif ( $action =~ /\/(\w+)$/ ) { $method = $1; } + elsif ( $action =~ /^(\w+)$/ ) { + $method = $action; + } + if ( $class && $method && $method !~ /^_/ ) { my $executed = sprintf( "%s->%s", $class, $method );