X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Action-REST.git;a=blobdiff_plain;f=t%2Fcatalyst-action-serialize-accept.t;fp=t%2Fcatalyst-action-serialize-accept.t;h=12f5df633ace56bd464eabeec1e001498904c138;hp=873a3796509b0a1af21c48ab5b03a20689227657;hb=c0aef9cd678b6b4e4ea557d7fa1e8f43153e00b0;hpb=d6fb033c1dbd94c0d527ec53291af2c50a482e9d diff --git a/t/catalyst-action-serialize-accept.t b/t/catalyst-action-serialize-accept.t index 873a379..12f5df6 100644 --- a/t/catalyst-action-serialize-accept.t +++ b/t/catalyst-action-serialize-accept.t @@ -18,6 +18,7 @@ __PACKAGE__->config( 'stash_key' => 'rest', 'map' => { 'text/x-yaml' => 'YAML', + 'application/json' => 'JSON', 'text/x-data-dumper' => [ 'Data::Serializer', 'Data::Dumper' ], 'text/broken' => 'Broken', }, @@ -44,10 +45,11 @@ package main; use strict; use warnings; -use Test::More tests => 7; +use Test::More tests => 10; use Data::Serializer; use FindBin; use Data::Dump qw(dump); +use JSON::Syck; use lib ("$FindBin::Bin/lib", "$FindBin::Bin/../lib", "$FindBin::Bin/broken"); use Test::Rest; @@ -72,6 +74,17 @@ EOH is( $res->header('Content-type'), 'text/x-yaml', '... with expected content-type') } +{ + my $at = Test::Rest->new('content_type' => 'text/doesnt-exist'); + my $req = $at->get(url => '/test'); + $req->header('Accept', 'application/json'); + my $res = request($req); + ok( $res->is_success, 'GET the serialized request succeeded' ); + my $ret = JSON::Syck::Load($res->content); + is( $ret->{lou}, 'is my cat', "Request returned proper data"); + is( $res->header('Content-type'), 'application/json', 'Accept header used if content-type mapping not found') +} + # Make sure we don't get a bogus content-type when using default # serializer (rt.cpan.org ticket 27949) {