Merged 5.49_01 (r1339) from refactored branch to trunk
[catagits/Catalyst-Runtime.git] / t / live / lib / TestApp / Controller / Action / Detach.pm
diff --git a/t/live/lib/TestApp/Controller/Action/Detach.pm b/t/live/lib/TestApp/Controller/Action/Detach.pm
new file mode 100644 (file)
index 0000000..28b0f8f
--- /dev/null
@@ -0,0 +1,45 @@
+package TestApp::Controller::Action::Detach;\r
+\r
+use strict;\r
+use base 'TestApp::Controller::Action';\r
+\r
+sub one : Local {\r
+    my ( $self, $c ) = @_;\r
+    $c->detach('two');\r
+    $c->forward('error');\r
+}\r
+\r
+sub two : Private {\r
+    my ( $self, $c ) = @_;\r
+    $c->forward('TestApp::View::Dump::Request');\r
+}\r
+\r
+sub error : Local {\r
+    my ( $self, $c ) = @_;\r
+    $c->res->output('error');\r
+}\r
+\r
+sub path : Local {\r
+    my ( $self, $c ) = @_;\r
+    $c->detach('/action/detach/two');\r
+    $c->forward('error');\r
+}\r
+\r
+sub with_args : Local {\r
+    my ( $self, $c, $orig ) = @_;\r
+    $c->detach( 'args', [qq/new/] );\r
+}\r
+\r
+sub with_method_and_args : Local {\r
+    my ( $self, $c, $orig ) = @_;\r
+    $c->detach( qw/TestApp::Controller::Action::Detach args/, [qq/new/] );\r
+}\r
+\r
+sub args : Local {\r
+    my ( $self, $c, $val ) = @_;\r
+    die "Expected argument 'new', got '$val'" unless $val eq 'new';\r
+    die "passed argument does not match args" unless $val eq $c->req->args->[0];\r
+    $c->res->body( $c->req->args->[0] );\r
+}\r
+\r
+1;\r