Merged 5.49_01 (r1339) from refactored branch to trunk
[catagits/Catalyst-Runtime.git] / t / live / component / controller / action / detach.t
diff --git a/t/live/component/controller/action/detach.t b/t/live/component/controller/action/detach.t
new file mode 100644 (file)
index 0000000..f33ee7a
--- /dev/null
@@ -0,0 +1,61 @@
+#!perl\r
+\r
+use strict;\r
+use warnings;\r
+\r
+use FindBin;\r
+use lib "$FindBin::Bin/../../../lib";\r
+\r
+use Test::More tests => 18;\r
+use Catalyst::Test 'TestApp';\r
+\r
+\r
+{\r
+    my @expected = qw[\r
+        TestApp::Controller::Action::Detach->begin\r
+        TestApp::Controller::Action::Detach->one\r
+        TestApp::Controller::Action::Detach->two\r
+        TestApp::View::Dump::Request->process\r
+    ];\r
+\r
+    my $expected = join( ", ", @expected );\r
+\r
+    # Test detach to chain of actions.\r
+    ok( my $response = request('http://localhost/action/detach/one'), 'Request' );\r
+    ok( $response->is_success, 'Response Successful 2xx' );\r
+    is( $response->content_type, 'text/plain', 'Response Content-Type' );\r
+    is( $response->header('X-Catalyst-Action'), 'action/detach/one', 'Test Action' );\r
+    is( $response->header('X-Test-Class'), 'TestApp::Controller::Action::Detach', 'Test Class' );\r
+    is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' );\r
+}\r
+\r
+{\r
+    my @expected = qw[\r
+        TestApp::Controller::Action::Detach->begin\r
+        TestApp::Controller::Action::Detach->path\r
+        TestApp::Controller::Action::Detach->two\r
+        TestApp::View::Dump::Request->process\r
+    ];\r
+\r
+    my $expected = join( ", ", @expected );\r
+\r
+    # Test detach to chain of actions.\r
+    ok( my $response = request('http://localhost/action/detach/path'), 'Request' );\r
+    ok( $response->is_success, 'Response Successful 2xx' );\r
+    is( $response->content_type, 'text/plain', 'Response Content-Type' );\r
+    is( $response->header('X-Catalyst-Action'), 'action/detach/path', 'Test Action' );\r
+    is( $response->header('X-Test-Class'), 'TestApp::Controller::Action::Detach', 'Test Class' );\r
+    is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' );\r
+}\r
+\r
+{\r
+    ok( my $response = request('http://localhost/action/detach/with_args/old'), 'Request with args' );\r
+    ok( $response->is_success, 'Response Successful 2xx' );\r
+    is( $response->content, 'new');\r
+}\r
+\r
+{\r
+    ok( my $response = request('http://localhost/action/detach/with_method_and_args/old'), 'Request with args and method' );\r
+    ok( $response->is_success, 'Response Successful 2xx' );\r
+    is( $response->content, 'new');\r
+}\r