From: Tomas Doran Date: Mon, 8 Feb 2010 20:14:56 +0000 (+0000) Subject: Add tests which should fail, but don't. X-Git-Tag: 0.83~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Action-REST.git;a=commitdiff_plain;h=960e29eed9ccd049c3c0dcd78a65308242a64ae0 Add tests which should fail, but don't. I think this is what was being got at in the mail http://lists.scsys.co.uk/pipermail/catalyst/2010-February/024582.html but these tests dont fail.. --- diff --git a/t/catalyst-action-serialize-accept.t b/t/catalyst-action-serialize-accept.t index 8b9408f..64732f5 100644 --- a/t/catalyst-action-serialize-accept.t +++ b/t/catalyst-action-serialize-accept.t @@ -1,6 +1,6 @@ use strict; use warnings; -use Test::More tests => 16; +use Test::More; use Data::Serializer; use FindBin; @@ -88,4 +88,14 @@ SKIP: { is( $res->header('Content-type'), 'text/x-data-dumper', '... with expected content-type') } -1; +# Make sure that the default content type you specify really gets used. +{ + my $req = $t->get(url => '/override/test'); + $req->remove_header('Content-Type'); + my $res = request($req); + ok( $res->is_success, 'GET the serialized request succeeded' ); + is( $res->content, "--- \nlou: is my cat\n", "Request returned proper data"); +} + +done_testing; + diff --git a/t/lib/Test/Catalyst/Action/REST/Controller/Override.pm b/t/lib/Test/Catalyst/Action/REST/Controller/Override.pm new file mode 100644 index 0000000..7bd0eae --- /dev/null +++ b/t/lib/Test/Catalyst/Action/REST/Controller/Override.pm @@ -0,0 +1,22 @@ +package Test::Catalyst::Action::REST::Controller::Override; + +use Moose; +use namespace::autoclean; + +BEGIN { extends 'Catalyst::Controller' } + +__PACKAGE__->config( + 'default' => 'application/json', + 'map' => { + 'application/json' => 'YAML', # Yes, this is deliberate! + }, +); + +sub test :Local :ActionClass('Serialize') { + my ( $self, $c ) = @_; + $c->stash->{'rest'} = { + lou => 'is my cat', + }; +} + +1;