Fix log link, add real tests for the links generated on the front page
Tomas Doran [Sat, 23 Jan 2010 15:23:36 +0000 (15:23 +0000)]
root/fragment/collectionofrepositories.tt2
t/app-mech-rootpage.t

index b69e69a..3f8d754 100644 (file)
@@ -8,7 +8,7 @@
     <td class="time-since">[% time_since(p.last_change) %]</td>
     <td class="link"><a href="[% repos_link %]">summary</a>
        | <a href="[% c.uri_for_action('/repository/shortlog', [p.name]) %]">shortlog</a>
-       | <a href="[% c.uri_for_action('/repository/log', [p.name]) %]">log</a>
+       | <a href="[% c.uri_for_action('/repository/longlog', [p.name]) %]">log</a>
        | <a href="[% c.uri_for_action('/commit/tree', [p.name, 'HEAD']) %]">tree</a></td>
 </tr>
   [% END %]
index 4f61327..8be8cf3 100644 (file)
@@ -5,6 +5,29 @@ use TestGitalist;
 plan 'skip_all' => 'No WWW::Mechanize' unless MECH();
 
 MECH->get_ok('/');
-ok MECH->findnodes_as_string('/html/body');
+{
+    my $nodeset = MECH->findnodes('/html/body//tr[@class="reposrow"]');
+    foreach my $row ($nodeset->get_nodelist) {
+        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'
+            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';
+        my ($summary, $shortlog, $log, $tree) = $row->findnodes('.//td[@class="link"]/a')->get_nodelist;
+        like $summary->as_text, qr/summary/i, 'summary text ok';
+        is $summary->attr('href'), $uri, 'summary href correct';
+        like $shortlog->as_text, qr/shortlog/i, 'shortlog text ok';
+        is $shortlog->attr('href'), "$uri/shortlog", 'shortlog href ok';
+        like $log->as_text, qr/log/, 'log text ok';
+        is $log->attr('href'), "$uri/log", 'log href ok';
+        like $tree->as_text, qr/tree/, 'tree text ok';
+        TODO: {
+            local $TODO = 'Bork';
+            is $tree->attr('href'), "$uri/tree", 'tree href ok';
+        }
+    }
+}
 
 done_testing;