Fixed the last few failing tests, in particular the /repo/sha1 action related fails.
Dan Brook [Fri, 12 Mar 2010 20:12:40 +0000 (20:12 +0000)]
* Added the /repo/sha1 action which just redirects to /ref/action with the
appropriate args.
* Fixed ref links.
* Made one of the assertions in the app-mech-rootpage.t test a little more forgiving.
* All tests should now be passing (bar TODO bits).

lib/Gitalist/URIStructure/Repository.pm
root/_refs.tt2
t/app-mech-rootpage.t
t/lib/TestGitalist.pm

index 47e7016..976917e 100644 (file)
@@ -30,6 +30,18 @@ before 'log' => sub {
     $c->stash->{Commit} = $c->stash->{Repository}->get_object($c->stash->{Repository}->head_hash);
 };
 
+sub object : Chained('find') PathPart('') Args(1) {
+    my ($self, $c, $sha1) = @_;
+
+    my $repo = $c->stash->{Repository};
+    my $obj  = $c->stash->{Commit} = $repo->get_object($sha1);
+    my($act) = (ref($obj) || '') =~ /::(\w+)$/;
+
+    $c->res->redirect($c->uri_for_action("/ref/\L$act", [$repo->name, $obj->sha1]));
+    $c->res->status(301);
+
+}
+
 sub summary : Chained('find') PathPart('') Args(0) {}
 
 sub heads : Chained('find') Args(0) {}
index 4c3893a..ec6db82 100644 (file)
@@ -1,7 +1,7 @@
 <span class='refs'>
  [% FOREACH ref IN refs.${object.sha1} %]
  <span class='[% ref.search('^remotes/') ? 'remote' : 'head' %]'>
-  <a href='[% c.uri_for_action("/repository/shortlog", [ref.match('(\w+)$').0]) %]'>[% ref.replace('^(remote|head)s/', '') %]</a>
+  <a href='[% c.uri_for_action("/repository/shortlog", [Repository, object.sha1]) %]'>[% ref.replace('^(remote|head)s/', '') %]</a>
  </span>
  [% END %]
 </span>
index ff4d5a4..cc6f71f 100644 (file)
@@ -11,7 +11,7 @@ MECH->get_ok('/');
         my $uri = $row->findnodes('.//a')->[0]->attr('href');
         my ($repos_name) = $uri =~ m{^http://localhost/([\w\.]+)$};
         ok $repos_name, "Repos name $repos_name";
-        like $row->findnodes('.//a')->[1]->as_text, qr/^[\w\s;'\.]+$/, 'Have description'
+        like $row->findnodes('.//a')->[1]->as_text, qr{^[\w\s/;',\.]+$}, 'Have description'
             unless $repos_name eq 'nodescription';
         like $row->findnodes('.//td[@class="time-since"')->[0]->as_text, qr/^(never|\d\s+(years|months)\s+ago)$/,
             'Last change looks ok';
index 05a2064..dcdc539 100644 (file)
@@ -73,7 +73,7 @@ sub test_uri {
     my $request = "/$uri"; 
     $request .= "?$qs" if defined $qs;
     my $response = request($request);
-    ok($response->is_success, "ok $request");
+    ok($response->is_success || $response->is_redirect, "ok $request");
     if (MECH) {
         my $res = MECH()->get($request);
         ok $res->is_success, "ok mech $request (" . $res->code . ')';