Fix for infinite loop bug in blame.
[catagits/Gitalist.git] / t / json_view.t
1 #!/usr/bin/env perl
2
3 use FindBin qw/$Bin/;
4 BEGIN {
5     my $env = "$FindBin::Bin/../script/env";
6     if (-r $env) {
7         do $env or die $@;
8     }
9 }
10
11 use strict;
12 use warnings;
13 use Test::More;
14 use HTTP::Request::Common;
15 use JSON::XS qw/decode_json encode_json/;
16
17 BEGIN {
18     $ENV{GITALIST_CONFIG} = $Bin;
19     $ENV{GITALIST_REPO_DIR} = '';
20     use_ok 'Catalyst::Test', 'Gitalist';
21 }
22
23 my $res = request(GET 'http://localhost/repo1', 'Content-Type' => 'application/json');
24 is $res->code, 200;
25 my $data = decode_json $res->content;
26 is ref($data), 'HASH';
27 delete $data->{owner}
28   if $data && exists $data->{owner};
29 is_deeply $data, {
30           'is_bare' => 1,
31           '__CLASS__' => 'Gitalist::Git::Repository',
32           'last_change' => '2011-06-05T23:00:44Z',
33           'name' => 'repo1',
34           'description' => 'some test repository'
35         };
36
37 done_testing;
38
39