fixed test failure in generic.t with Moose > 2.02
[catagits/Catalyst-Controller-DBIC-API.git] / t / rpc / setup_dbic_args.t
1 use strict;
2 use warnings;
3
4 use lib 't/lib';
5
6 my $base = 'http://localhost';
7
8 use RestTest;
9 use DBICTest;
10 use URI;
11 use Test::More;
12 use Test::WWW::Mechanize::Catalyst 'RestTest';
13 use HTTP::Request::Common;
14 use JSON;
15
16 my $json = JSON->new->utf8;
17
18 my $mech = Test::WWW::Mechanize::Catalyst->new;
19 ok( my $schema = DBICTest->init_schema(), 'got schema' );
20
21 my $track_list_url = "$base/api/rpc/track_setup_dbic_args/list";
22 my $base_rs =
23     $schema->resultset('Track')
24     ->search( {},
25     { select => [qw/me.title me.position/], order_by => 'position' } );
26
27 # test open request
28 {
29     my $req = GET(
30         $track_list_url,
31         {
32
33         },
34         'Accept' => 'text/x-json'
35     );
36     $mech->request($req);
37     cmp_ok( $mech->status, '==', 200, 'open attempt okay' );
38
39     my @expected_response = map {
40         { $_->get_columns }
41     } $base_rs->search( { position => { '!=' => '1' } } )->all;
42     my $response = $json->decode( $mech->content );
43     is_deeply( { list => \@expected_response, success => 'true' },
44         $response, 'correct message returned' );
45 }
46
47 done_testing();