Fix .gitignore for new dist name
[catagits/Catalyst-Action-Serialize-Data-Serializer.git] / t / lib / Test / Catalyst / Action / REST / Controller / Serialize.pm
index 4894c02..61b502e 100644 (file)
@@ -1,17 +1,15 @@
 package Test::Catalyst::Action::REST::Controller::Serialize;
 
-use strict;
-use warnings;
-use base 'Catalyst::Controller';
+use Moose;
+use namespace::autoclean;
+
+BEGIN { extends 'Catalyst::Controller' }
 
 __PACKAGE__->config(
     'default'   => 'text/x-yaml',
     'stash_key' => 'rest',
     'map'       => {
-        'text/x-yaml'        => 'YAML',
-        'application/json'   => 'JSON',
         'text/x-data-dumper' => [ 'Data::Serializer', 'Data::Dumper' ],
-        'text/broken'        => 'Broken',
     },
 );
 
@@ -31,4 +29,26 @@ sub test_second :Local :ActionClass('Serialize') {
     };
 }
 
+# For testing saying 'here is an explicitly empty body, do not serialize'
+sub empty : Chained('/') PathPart('serialize') CaptureArgs(0) {
+    my ($self, $c) = @_;
+    $c->stash( rest => { foo => 'bar' } );
+}
+
+# Normal case
+sub empty_serialized :Chained('empty') Args(0) ActionClass('Serialize') {
+}
+
+# Blank body
+sub empty_not_serialized_blank :Chained('empty') Args(0) ActionClass('Serialize') {
+    my ($self, $c) = @_;
+    $c->res->body('');
+}
+
+# Explicitly set a view
+sub explicit_view :Chained('empty') Args(0) ActionClass('Serialize') {
+    my ($self, $c) = @_;
+    $c->stash->{current_view} = '';
+}
+
 1;