Split into new dist
[catagits/Catalyst-Action-Serialize-Data-Serializer.git] / t / lib / Test / Catalyst / Action / REST / Controller / Serialize.pm
CommitLineData
74bc96b9 1package Test::Catalyst::Action::REST::Controller::Serialize;
2
930013e6 3use Moose;
4use namespace::autoclean;
5
6BEGIN { extends 'Catalyst::Controller' }
74bc96b9 7
8__PACKAGE__->config(
9 'default' => 'text/x-yaml',
10 'stash_key' => 'rest',
74bc96b9 11 'map' => {
74bc96b9 12 'text/x-data-dumper' => [ 'Data::Serializer', 'Data::Dumper' ],
74bc96b9 13 },
14);
15
16sub test :Local :ActionClass('Serialize') {
17 my ( $self, $c ) = @_;
18 $c->stash->{'rest'} = {
19 lou => 'is my cat',
20 };
21}
22
23sub test_second :Local :ActionClass('Serialize') {
24 my ( $self, $c ) = @_;
0d86eca6 25 # 'serialize_content_type' is configured in the test config in t/conf
74bc96b9 26 $c->stash->{'serialize_content_type'} = $c->req->params->{'serialize_content_type'};
27 $c->stash->{'rest'} = {
28 lou => 'is my cat',
29 };
30}
31
786c212f 32# For testing saying 'here is an explicitly empty body, do not serialize'
33sub empty : Chained('/') PathPart('serialize') CaptureArgs(0) {
34 my ($self, $c) = @_;
35 $c->stash( rest => { foo => 'bar' } );
36}
37
38# Normal case
39sub empty_serialized :Chained('empty') Args(0) ActionClass('Serialize') {
40}
41
786c212f 42# Blank body
43sub empty_not_serialized_blank :Chained('empty') Args(0) ActionClass('Serialize') {
44 my ($self, $c) = @_;
45 $c->res->body('');
46}
47
fb9d509b 48# Explicitly set a view
49sub explicit_view :Chained('empty') Args(0) ActionClass('Serialize') {
50 my ($self, $c) = @_;
51 $c->stash->{current_view} = '';
52}
53
74bc96b9 541;