Merge and cleanup
Tomas Doran [Sat, 7 Nov 2009 19:36:37 +0000 (19:36 +0000)]
lib/Gitalist/Controller/Root.pm
t/01app.t

index 9d951d4..798e267 100644 (file)
@@ -66,7 +66,8 @@ sub _get_commit {
 
   # FIXME this can die when everything is migrated
   my ($m, $pd);
-  if ($c->stash->{current_model} eq 'GitRepos') {
+  if (defined $c->stash->{current_model} &&
+          $c->stash->{current_model} eq 'GitRepos') {
       $m = $c->model()->project($c->stash->{project});
       $pd = $m->path;
   } else {
@@ -582,7 +583,8 @@ sub end : ActionClass('RenderView') {
   my ($self, $c) = @_;
   # Give project views the current HEAD.
   if ($c->stash->{project}) {
-      if ($c->stash->{current_model} eq 'GitRepos') {
+      if ($c->stash->{current_model} &&
+              $c->stash->{current_model} eq 'GitRepos') {
           my $project = $c->model()->project($c->stash->{project});
           $c->stash->{HEAD} = $project->head_hash;
       } else {
index 8ffabe1..8946b80 100644 (file)
--- a/t/01app.t
+++ b/t/01app.t
@@ -10,6 +10,7 @@ BEGIN {
 }
 
 ok( request('/')->is_success, 'Request should succeed' );
+
 for my $p (qw/ bare.git repo1 nodescription /) {
     my $path = '/summary?p=' . $p;
     ok( request($path)->is_success, "$path should succeed");
@@ -17,6 +18,33 @@ for my $p (qw/ bare.git repo1 nodescription /) {
 
 is request('/summary?p=DoesNotExist')->code, 404,
     '/summary?p=DoesNotExist 404s';
+{
+  # URI tests for repo1
+  local *test = curry_test_uri('repo1');
+  test('/summary');
+  test('/shortlog');
+  test('/log');
+  test('/commit');
+  test('/commitdiff', 'h=36c6c6708b8360d7023e8a1649c45bcf9b3bd818');
+  test('/tree', 'h=145dc3ef5d307be84cb9b325d70bd08aeed0eceb;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818');
+#  $test_repo1->('/', 'a=blob;f=file1');
+}
 
 done_testing;
 
+sub test_uri {
+    my ($p, $uri, $qs) = @_;
+    $qs ||= '';
+    my $request = "$uri?p=repo1;$qs";
+    warn("request: $request");
+    my $response = request($request);
+    ok($response->is_success, "ok $p - $uri");
+}
+
+sub curry_test_uri {
+    my $p = shift;
+    sub {
+        my $uri = shift;
+        test_uri($p, $uri);
+    };
+};