A few fixes to get the JSON test working.
Dan Brook [Sun, 2 May 2010 21:01:55 +0000 (22:01 +0100)]
Reinstate a couple of changes lost in the merge and update some of the
docs to be in line with swann.
The Repository is now exposed for JSON requests.

16 files changed:
lib/Gitalist/Git/Repository.pm
lib/Gitalist/URIStructure/Repository.pm
t/01app.t
t/02git_CollectionOfRepositories_FromDirectory.t
t/02git_Repository.t
t/02git_object.t
t/02git_util.t
t/03legacy_uri.t
t/app-mech-rootpage.t
t/atom.t
t/json_view.t
t/model_collectionofrepos.t
t/opml.t
t/rss.t
t/scripts.t
t/view_Default.t

index 5e27b6f..05ddc9f 100644 (file)
@@ -74,7 +74,7 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
                         lazy_build => 1 );
 
     method BUILD {
-        $self->$_() for qw/last_change owner description/; # Ensure to build early.
+        $self->$_() for qw/last_change owner description references/; # Ensure to build early.
     }
 
     ## Public methods
index 976917e..1bdf691 100644 (file)
@@ -18,6 +18,7 @@ sub find : Chained('base') PathPart('') CaptureArgs(1) {
         $c->stash(
             Repository => $repos,
             HEAD => $repos->head_hash,
+            data => $repos,
         );
     }
     catch {
index f52f36e..171a349 100644 (file)
--- a/t/01app.t
+++ b/t/01app.t
@@ -1,5 +1,6 @@
 #!/usr/bin/env perl
 use FindBin qw/$Bin/;
+BEGIN { do "$FindBin::Bin/../script/env" or die $@ }
 use lib "$Bin/lib";
 use TestGitalist;
 
index 41f7699..1a09bf9 100644 (file)
@@ -1,6 +1,7 @@
+use FindBin qw/$Bin/;
+BEGIN { do "$FindBin::Bin/../script/env" or die $@ }
 use strict;
 use warnings;
-use FindBin qw/$Bin/;
 use Test::More qw/no_plan/;
 use Test::Exception;
 
index bf4791b..5119932 100644 (file)
@@ -1,6 +1,7 @@
+use FindBin qw/$Bin/;
+BEGIN { do "$FindBin::Bin/../script/env" or die $@ }
 use strict;
 use warnings;
-use FindBin qw/$Bin/;
 use Test::More qw/no_plan/;
 use Test::Exception;
 use Test::utf8;
index e85197b..0ae1a2f 100644 (file)
@@ -1,6 +1,7 @@
+use FindBin qw/$Bin/;
+BEGIN { do "$FindBin::Bin/../script/env" or die $@ }
 use strict;
 use warnings;
-use FindBin qw/$Bin/;
 use Test::More;
 use Test::Exception;
 use Data::Dumper;
index 94f82f7..a3fe51b 100644 (file)
@@ -1,6 +1,7 @@
+use FindBin qw/$Bin/;
+BEGIN { do "$FindBin::Bin/../script/env" or die $@ }
 use strict;
 use warnings;
-use FindBin qw/$Bin/;
 use Test::More;
 
 use Data::Dumper;
index 839d794..ff3609d 100644 (file)
@@ -1,5 +1,6 @@
 #!/usr/bin/env perl
 use FindBin qw/$Bin/;
+BEGIN { do "$FindBin::Bin/../script/env" or die $@ }
 use lib "$Bin/lib";
 use TestGitalist qw/request curry_test_uri done_testing ok is $TODO/;
 
index cc6f71f..a51da3f 100644 (file)
@@ -1,5 +1,6 @@
 #!/usr/bin/env perl
 use FindBin qw/$Bin/;
+BEGIN { do "$FindBin::Bin/../script/env" or die $@ }
 use lib "$Bin/lib";
 use TestGitalist;
 plan 'skip_all' => "One or more of the following modules aren't present: Test::WWW::Mechanize::Catalyst WWW::Mechanize::TreeBuilder HTML::TreeBuilder::XPath" unless MECH();
index 13c835f..d4de77d 100644 (file)
--- a/t/atom.t
+++ b/t/atom.t
@@ -1,5 +1,6 @@
 #!/usr/bin/env perl
 use FindBin qw/$Bin/;
+BEGIN { do "$FindBin::Bin/../script/env" or die $@ }
 use lib "$Bin/lib";
 use TestGitalist;
 
index 026479d..b32a0a6 100644 (file)
@@ -1,11 +1,15 @@
 #!/usr/bin/env perl
+
+use FindBin qw/$Bin/;
+BEGIN { do "$FindBin::Bin/../script/env" or die $@ }
+
 use strict;
 use warnings;
 use Test::More;
 use HTTP::Request::Common;
-use FindBin qw/$Bin/;
 use JSON::Any;
 
+
 BEGIN {
     $ENV{GITALIST_CONFIG} = $Bin;
     $ENV{GITALIST_REPO_DIR} = '';
@@ -14,12 +18,13 @@ BEGIN {
 
 my $j = JSON::Any->new;
 
-my $res = request(GET 'http://localhost/summary?p=repo1', 'Content-Type' => 'application/json');
+my $res = request(GET 'http://localhost/repo1', 'Content-Type' => 'application/json');
 is $res->code, 200;
 my $data = $j->decode($res->content);
 is ref($data), 'HASH';
+delete $data->{owner}
+  if $data && exists $data->{owner};
 is_deeply $data, {
-          'owner' => 'Tomas Doran',
           'is_bare' => 1,
           '__CLASS__' => 'Gitalist::Git::Repository',
           'last_change' => '2009-11-12T19:00:34Z',
@@ -28,7 +33,8 @@ is_deeply $data, {
                                                                             'heads/branch1'
                                                                           ],
                             '36c6c6708b8360d7023e8a1649c45bcf9b3bd818' => [
-                                                                            'heads/master'
+                                                                            'heads/master',
+                                                                            'tags/0.01'
                                                                           ]
                           },
           'name' => 'repo1',
index e847c33..ae1a6a9 100644 (file)
@@ -1,3 +1,5 @@
+use FindBin qw/$Bin/;
+BEGIN { do "$FindBin::Bin/../script/env" or die $@ }
 use strict;
 use warnings;
 
index d468b44..b5bb93c 100644 (file)
--- a/t/opml.t
+++ b/t/opml.t
@@ -1,5 +1,6 @@
 #!/usr/bin/env perl
 use FindBin qw/$Bin/;
+BEGIN { do "$FindBin::Bin/../script/env" or die $@ }
 use lib "$Bin/lib";
 use TestGitalist;
 
diff --git a/t/rss.t b/t/rss.t
index 2d6a143..c9c3804 100644 (file)
--- a/t/rss.t
+++ b/t/rss.t
@@ -1,5 +1,6 @@
 #!/usr/bin/env perl
 use FindBin qw/$Bin/;
+BEGIN { do "$FindBin::Bin/../script/env" or die $@ }
 use lib "$Bin/lib";
 use TestGitalist;
 
index 2402921..e39bd13 100644 (file)
@@ -1,3 +1,6 @@
+use FindBin qw/$Bin/;
+BEGIN { do "$FindBin::Bin/../script/env" or die $@ }
+
 use strict;
 use warnings;
 use Test::More;
index 9e93920..07940ce 100644 (file)
@@ -1,3 +1,6 @@
+use FindBin qw/$Bin/;
+BEGIN { do "$FindBin::Bin/../script/env" or die $@ }
+
 use strict;
 use warnings;
 use Test::More tests => 1;