From: Zachary Stevens Date: Sat, 7 Nov 2009 19:44:56 +0000 (+0000) Subject: Add some tests for legacy URI compatibility, and fix the index action X-Git-Tag: 0.000000_01~68^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=46aab84dd8706078984df634b0384833872a2688;p=catagits%2FGitalist.git Add some tests for legacy URI compatibility, and fix the index action so they work (except for one). --- diff --git a/lib/Gitalist/Controller/Root.pm b/lib/Gitalist/Controller/Root.pm index 798e267..91d0255 100644 --- a/lib/Gitalist/Controller/Root.pm +++ b/lib/Gitalist/Controller/Root.pm @@ -95,22 +95,20 @@ Provides the project listing. =cut sub index :Path :Args(0) { - my ( $self, $c ) = @_; - $c->stash(current_model => 'GitRepos'); - # Leave actions up to gitweb at this point. - return $self->run_gitweb($c) - if $c->req->param('a'); - - my $list = $c->model()->list_projects; - unless(@$list) { - die "No projects found in ". $c->model->repo_dir; - } + my ( $self, $c ) = @_; + $c->detach($c->req->param('a')) if $c->req->param('a'); + $c->stash(current_model => 'GitRepos'); - $c->stash( - searchtext => $c->req->param('searchtext') || '', - projects => $list, - action => 'index', - ); + my $list = $c->model()->list_projects; + unless(@$list) { + die "No projects found in ". $c->model->repo_dir; + } + + $c->stash( + searchtext => $c->req->param('searchtext') || '', + projects => $list, + action => 'index', + ); } =head2 summary diff --git a/t/01app.t b/t/01app.t index 267e805..1c69c5b 100644 --- a/t/01app.t +++ b/t/01app.t @@ -20,11 +20,21 @@ SKIP: { use Data::Dumper; my $test_repo1 = curry_test_uri('repo1'); &$test_repo1('/summary'); + &$test_repo1('/heads'); &$test_repo1('/shortlog'); &$test_repo1('/log'); &$test_repo1('/commit'); - &$test_repo1('/commitdiff', 'h=36c6c6708b8360d7023e8a1649c45bcf9b3bd818'); - &$test_repo1('/tree', 'h=145dc3ef5d307be84cb9b325d70bd08aeed0eceb;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818'); + &$test_repo1('/commitdiff'); + &$test_repo1('/tree'); + + # legacy URIs + &$test_repo1('/', 'a=summary'); + &$test_repo1('/', 'a=heads'); + &$test_repo1('/', 'a=shortlog'); + &$test_repo1('/', 'a=log'); + &$test_repo1('/', 'a=commit'); + &$test_repo1('/', 'a=commitdiff'); + &$test_repo1('/', 'a=tree'); # &$test_repo1('/', 'a=blob;f=file1'); } # Close APP_TEST skip @@ -41,7 +51,7 @@ sub test_uri { sub curry_test_uri { my $p = shift; sub { - my $uri = shift; - test_uri($p, $uri); + my ($uri, $qs) = @_; + test_uri($p, $uri, $qs); }; };