From: Tomas Doran (t0m) Date: Sat, 25 Jul 2009 10:25:33 +0000 (+0100) Subject: Merge cherry pick of whitespace cleanups X-Git-Tag: 0.75~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Action-REST.git;a=commitdiff_plain;h=21d3f6aeb5d5150d2709f9a3d0647d21e9d74d9b Merge cherry pick of whitespace cleanups --- diff --git a/lib/Catalyst/Controller/REST.pm b/lib/Catalyst/Controller/REST.pm index e6036d9..6016c65 100644 --- a/lib/Catalyst/Controller/REST.pm +++ b/lib/Catalyst/Controller/REST.pm @@ -167,8 +167,8 @@ you serialize be a HASHREF, we transform outgoing data to be in the form of: Uses a regular Catalyst view. For example, if you wanted to have your C and C views rendered by TT: - 'text/html' => [ 'View', 'TT' ], - 'text/xml' => [ 'View', 'XML' ], + 'text/html' => [ 'View', 'TT' ], + 'text/xml' => [ 'View', 'XML' ], Will do the trick nicely. @@ -179,7 +179,7 @@ response if an attempt to use an unsupported content-type is made. You can ensure that something is always returned by setting the C config option: - __PACKAGE__->config->{'default'} = 'text/x-yaml'; + __PACKAGE__->config->{'default'} = 'text/x-yaml'; Would make it always fall back to the serializer plugin defined for text/x-yaml. diff --git a/t/catalyst-action-serialize-accept.t b/t/catalyst-action-serialize-accept.t index 2e268e0..bea3d3a 100644 --- a/t/catalyst-action-serialize-accept.t +++ b/t/catalyst-action-serialize-accept.t @@ -7,30 +7,30 @@ use FindBin; use lib ("$FindBin::Bin/lib", "$FindBin::Bin/../lib", "$FindBin::Bin/broken"); use Test::Rest; -# Should use Data::Dumper, via YAML +# Should use Data::Dumper, via YAML my $t = Test::Rest->new('content_type' => 'text/x-yaml'); use_ok 'Catalyst::Test', 'Test::Catalyst::Action::REST'; my $data = <get(url => '/serialize/test'); - $req->remove_header('Content-Type'); - $req->header('Accept', 'text/x-yaml'); - my $res = request($req); + my $req = $t->get(url => '/serialize/test'); + $req->remove_header('Content-Type'); + $req->header('Accept', 'text/x-yaml'); + my $res = request($req); SKIP: { skip "can't test text/x-yaml without YAML support", - 3 if ( - not $res->is_success and - $res->content =~ m#Content-Type text/x-yaml is not supported# + 3 if ( + not $res->is_success and + $res->content =~ m#Content-Type text/x-yaml is not supported# ); - ok( $res->is_success, 'GET the serialized request succeeded' ); - is( $res->content, $data, "Request returned proper data"); - is( $res->header('Content-type'), 'text/x-yaml', '... with expected content-type') + ok( $res->is_success, 'GET the serialized request succeeded' ); + is( $res->content, $data, "Request returned proper data"); + is( $res->header('Content-type'), 'text/x-yaml', '... with expected content-type') }; } @@ -40,9 +40,9 @@ SKIP: { skip "can't test application/json without JSON support", 3 if $@; my $json = JSON->new; my $at = Test::Rest->new('content_type' => 'text/doesnt-exist'); - my $req = $at->get(url => '/serialize/test'); - $req->header('Accept', 'application/json'); - my $res = request($req); + my $req = $at->get(url => '/serialize/test'); + $req->header('Accept', 'application/json'); + my $res = request($req); ok( $res->is_success, 'GET the serialized request succeeded' ); my $ret = $json->decode($res->content); is( $ret->{lou}, 'is my cat', "Request returned proper data"); @@ -52,39 +52,39 @@ SKIP: { # Make sure we don't get a bogus content-type when using default # serializer (rt.cpan.org ticket 27949) { - my $req = $t->get(url => '/serialize/test'); - $req->remove_header('Content-Type'); - $req->header('Accept', '*/*'); - my $res = request($req); - ok( $res->is_success, 'GET the serialized request succeeded' ); - is( $res->content, $data, "Request returned proper data"); - is( $res->header('Content-type'), 'text/x-yaml', '... with expected content-type') + my $req = $t->get(url => '/serialize/test'); + $req->remove_header('Content-Type'); + $req->header('Accept', '*/*'); + my $res = request($req); + ok( $res->is_success, 'GET the serialized request succeeded' ); + is( $res->content, $data, "Request returned proper data"); + is( $res->header('Content-type'), 'text/x-yaml', '... with expected content-type') } # Make that using content_type_stash_key, an invalid value in the stash gets ignored { - my $req = $t->get(url => '/serialize/test_second?serialize_content_type=nonesuch'); - $req->remove_header('Content-Type'); - $req->header('Accept', '*/*'); - my $res = request($req); - ok( $res->is_success, 'GET the serialized request succeeded' ); - is( $res->content, $data, "Request returned proper data"); - is( $res->header('Content-type'), 'text/x-yaml', '... with expected content-type') + my $req = $t->get(url => '/serialize/test_second?serialize_content_type=nonesuch'); + $req->remove_header('Content-Type'); + $req->header('Accept', '*/*'); + my $res = request($req); + ok( $res->is_success, 'GET the serialized request succeeded' ); + is( $res->content, $data, "Request returned proper data"); + is( $res->header('Content-type'), 'text/x-yaml', '... with expected content-type') } # Make that using content_type_stash_key, a valid value in the stash gets priority # this also tests that application-level config is properly passed to # individual controllers; see t/lib/Test/Catalyst/Action/REST.pm { - my $req = $t->get(url => - '/serialize/test_second?serialize_content_type=text/x-data-dumper' - ); - $req->remove_header('Content-Type'); - $req->header('Accept', '*/*'); - my $res = request($req); - ok( $res->is_success, 'GET the serialized request succeeded' ); - is( $res->content, "{'lou' => 'is my cat'}", "Request returned proper data"); - is( $res->header('Content-type'), 'text/x-data-dumper', '... with expected content-type') + my $req = $t->get(url => + '/serialize/test_second?serialize_content_type=text/x-data-dumper' + ); + $req->remove_header('Content-Type'); + $req->header('Accept', '*/*'); + my $res = request($req); + ok( $res->is_success, 'GET the serialized request succeeded' ); + is( $res->content, "{'lou' => 'is my cat'}", "Request returned proper data"); + is( $res->header('Content-type'), 'text/x-data-dumper', '... with expected content-type') } 1; diff --git a/t/lib/Test/Serialize/Controller/REST.pm b/t/lib/Test/Serialize/Controller/REST.pm index 0499f1d..733508a 100644 --- a/t/lib/Test/Serialize/Controller/REST.pm +++ b/t/lib/Test/Serialize/Controller/REST.pm @@ -31,11 +31,11 @@ __PACKAGE__->config( sub monkey_put : Local : ActionClass('Deserialize') { my ( $self, $c ) = @_; - if ( ref($c->req->data) eq "HASH" ) { - $c->res->output( $c->req->data->{'sushi'} ); - } else { - $c->res->output(1); - } + if ( ref($c->req->data) eq "HASH" ) { + $c->res->output( $c->req->data->{'sushi'} ); + } else { + $c->res->output(1); + } } sub monkey_get : Local : ActionClass('Serialize') { @@ -44,4 +44,3 @@ sub monkey_get : Local : ActionClass('Serialize') { } 1; - diff --git a/t/lib/Test/Serialize/View/Simple.pm b/t/lib/Test/Serialize/View/Simple.pm index b0c1990..049152d 100644 --- a/t/lib/Test/Serialize/View/Simple.pm +++ b/t/lib/Test/Serialize/View/Simple.pm @@ -3,10 +3,10 @@ package Test::Serialize::View::Simple; use base qw/Catalyst::View/; sub process { - my ($self, $c) = @_; - + my ($self, $c) = @_; + $c->res->body("I am a simple view"); - return 1; + return 1; } 1;