Add RESTful Content-Type bits to the root controller, add a simple test for summary...
[catagits/Gitalist.git] / t / json_view.t
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 use Test::More;
5 use HTTP::Request::Common;
6 use FindBin qw/$Bin/;
7 use JSON::Any;
8
9 BEGIN {
10     $ENV{GITALIST_CONFIG} = $Bin;
11     $ENV{GITALIST_REPO_DIR} = '';
12     use_ok 'Catalyst::Test', 'Gitalist';
13 }
14
15 my $j = JSON::Any->new;
16
17 my $res = request(GET 'http://localhost/summary?p=repo1', 'Content-Type' => 'application/json');
18 is $res->code, 200;
19 my $data = $j->decode($res->content);
20 is ref($data), 'HASH';
21 is_deeply $data, {
22           'owner' => 'Tomas Doran',
23           'is_bare' => 1,
24           '__CLASS__' => 'Gitalist::Git::Repository',
25           'last_change' => '2009-11-12T19:00:34Z',
26           'references' => {
27                             '0710a7c8ee11c73e8098d08f9384c2a839c65e4e' => [
28                                                                             'heads/branch1'
29                                                                           ],
30                             '36c6c6708b8360d7023e8a1649c45bcf9b3bd818' => [
31                                                                             'heads/master'
32                                                                           ]
33                           },
34           'name' => 'repo1',
35           'description' => 'some test repository'
36         };
37
38 done_testing;
39
40