t::Common;
use JSON;
use lib qw(t/lib);
use Test::WWW::Mechanize::Catalyst 'MyApp';
my $mech = Test::WWW::Mechanize::Catalyst->new();
$mech->add_header('Accept' => 'application/json');
$mech->get
$json = JSON::decode_json($mech->content), 'response is JSON response');
is($json->{results}, 0, 'no results');
my $res = $mech->request(POST '/user', [name => 'bar', password => 'foo']);
ok($json
= JSON::decode_json($res->content), 'response is JSON response');
is($json->{success}, 'true', 'submission was successful');
is($res->header('location'), 'http://localhost/user/1', 'user location is
use HTML::FormFu::ExtJS 0.076;
use Path::Class;
use HTML::Entities;
use Lingua::EN::Inflect;
use JSON;
use Try::Tiny;
use Moose::Util::TypeConstraints;
subtype 'PathClassDir', as 'Path::Class::Dir';
'stash_key'}
)
|| 'rest';
my $output;
eval { $output = encode_json( $c->stash->{$stash_key} ); };
$c->res->content_type('text/html');
$c->res->outp
({ ... });
1;
# set the Accept header to 'application/json' globally
Ext.Ajax.defaultHeaders = {
'Accept': 'application/json'
};
=head1 DESCRIPTION
This controller will make CRUD op