From: Dan Brook Date: Fri, 12 Mar 2010 20:12:40 +0000 (+0000) Subject: Fixed the last few failing tests, in particular the /repo/sha1 action related fails. X-Git-Tag: 0.000006_01~1^2~1^2~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FGitalist.git;a=commitdiff_plain;h=a8ae825fcb0f42f0f85c33bed7fb87239e7296da Fixed the last few failing tests, in particular the /repo/sha1 action related fails. * 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). --- diff --git a/lib/Gitalist/URIStructure/Repository.pm b/lib/Gitalist/URIStructure/Repository.pm index 47e7016..976917e 100644 --- a/lib/Gitalist/URIStructure/Repository.pm +++ b/lib/Gitalist/URIStructure/Repository.pm @@ -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) {} diff --git a/root/_refs.tt2 b/root/_refs.tt2 index 4c3893a..ec6db82 100644 --- a/root/_refs.tt2 +++ b/root/_refs.tt2 @@ -1,7 +1,7 @@ [% FOREACH ref IN refs.${object.sha1} %] - [% ref.replace('^(remote|head)s/', '') %] + [% ref.replace('^(remote|head)s/', '') %] [% END %] diff --git a/t/app-mech-rootpage.t b/t/app-mech-rootpage.t index ff4d5a4..cc6f71f 100644 --- a/t/app-mech-rootpage.t +++ b/t/app-mech-rootpage.t @@ -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'; diff --git a/t/lib/TestGitalist.pm b/t/lib/TestGitalist.pm index 05a2064..dcdc539 100644 --- a/t/lib/TestGitalist.pm +++ b/t/lib/TestGitalist.pm @@ -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 . ')';