Add mech testing in from the branch I previously made. 5 of the URIs which we test...
Tomas Doran [Thu, 21 Jan 2010 00:09:17 +0000 (00:09 +0000)]
Makefile.PL
lib/Gitalist/Controller/Root.pm
root/_footer_feeds.tt2
root/_log_pager.tt2
root/commit/shortlog.tt2 [new file with mode: 0644]
root/fragment/commit/diff_fancy.tt2
root/inc/log_pager.tt2
t/01app.t
t/03legacy_uri.t
t/lib/TestGitalist.pm [new file with mode: 0644]

index 0769bc7..de2a6b2 100644 (file)
@@ -107,6 +107,14 @@ if ($Module::Install::AUTHOR) {
         and die $!;
 }
 
+if ($ENV{GITALIST_RELEASE_TESTING}) {
+    author_tests 't/author';
+    author_requires 'Test::NoTabs';
+    author_requires 'Test::Pod' => '1.14';
+    author_requires 'Test::Pod::Coverage' => '1.04';
+    author_requires 'Test::WWW::Mechanize::Catalyst' => '0.51';
+}
+
 install_script glob('script/*.pl');
 auto_install;
 
index a846a77..4210ddc 100644 (file)
@@ -34,7 +34,7 @@ sub base : Chained('/root') PathPart('') CaptureArgs(0) {
     short_cmt => sub {
       my $cmt = shift;
       my($line) = split /\n/, $cmt;
-      $line =~ s/^(.{70,80}\b).*/$1 \x{2026}/;
+      $line =~ s/^(.{70,80}\b).*/$1 \x{2026}/ if defined $line;
       return $line;
     },
     abridged_description => sub {
index 3e99e51..b99a5ee 100644 (file)
     <a
       class="rss_logo"
       title="[% feed_title %]"
-      href="[% c.uri_for('rss', feed_args) %]">RSS</a>
+      href="[% c.uri_for_action('/repository/rss', [Repository.name]) %]">RSS</a>
     <a
       class="rss_logo"
       title="[% feed_title %]"
-      href="[% c.uri_for('atom', feed_args) %]">Atom</a>
+      href="[% c.uri_for_action('/repository/atom', [Repository.name]) %]">Atom</a>
   [% ELSE %]
     <a
       class="rss_logo"
-      href="[% c.uri_for('opml') %]">OPML</a>
+      href="[% c.uri_for_action('/opml/opml') %]">OPML</a>
     <a
       class="rss_logo"
-      href="[% c.uri_for('repository_index') %]">TXT</a>
+      href="[% c.uri_for('/repository_index') %]">TXT</a>
   [% END %]
index c332d35..e98f0ee 100644 (file)
@@ -1,9 +1,9 @@
 <div class='pager'>
- <a href='[% c.uri_for(action, {h=HEAD}) %]'>HEAD</a> &sect;
+ <a href='[% c.uri_for_action('/' _ c.action, [Repository.name, 'HEAD']) %]'>HEAD</a> &sect;
  [% IF log_lines.first.sha1 != commit.sha1 %]
- <a href='[% c.request.uri_with(pg => page - 1) %]'>&laquo; prev</a>
+ <a href='[% c.request.uri_with(pg => (page||0) - 1) %]'>&laquo; prev</a>
  [% END %]
  [% IF log_lines.size == 50 %]
- <a href='[% c.request.uri_with(pg => page + 1) %]'>next &raquo;</a>
+ <a href='[% c.request.uri_with(pg => (page||0) + 1) %]'>next &raquo;</a>
  [% END %]
 </div>
diff --git a/root/commit/shortlog.tt2 b/root/commit/shortlog.tt2
new file mode 100644 (file)
index 0000000..9d6cf4b
--- /dev/null
@@ -0,0 +1 @@
+FIXME
index 58a3943..3a6ad5e 100644 (file)
@@ -1,9 +1,9 @@
 MOO[%
   # In the case of merge commits there will be no diff tree.
-  IF diff_tree.size > 0;
+  IF (diff_tree.size||0) > 0;
     INCLUDE '_diff_tree.tt2';
   END;
-  IF diff.size > 0;
+  IF (diff.size||0) > 0;
     INCLUDE '_diff.tt2';
   ELSE
   %]
index c332d35..e98f0ee 100644 (file)
@@ -1,9 +1,9 @@
 <div class='pager'>
- <a href='[% c.uri_for(action, {h=HEAD}) %]'>HEAD</a> &sect;
+ <a href='[% c.uri_for_action('/' _ c.action, [Repository.name, 'HEAD']) %]'>HEAD</a> &sect;
  [% IF log_lines.first.sha1 != commit.sha1 %]
- <a href='[% c.request.uri_with(pg => page - 1) %]'>&laquo; prev</a>
+ <a href='[% c.request.uri_with(pg => (page||0) - 1) %]'>&laquo; prev</a>
  [% END %]
  [% IF log_lines.size == 50 %]
- <a href='[% c.request.uri_with(pg => page + 1) %]'>next &raquo;</a>
+ <a href='[% c.request.uri_with(pg => (page||0) + 1) %]'>next &raquo;</a>
  [% END %]
 </div>
index 68d3bf4..4742567 100644 (file)
--- a/t/01app.t
+++ b/t/01app.t
@@ -3,12 +3,14 @@ use strict;
 use warnings;
 use Test::More;
 use FindBin qw/$Bin/;
+use lib "$Bin/lib";
 
 BEGIN {
     $ENV{GITALIST_CONFIG} = $Bin;
     $ENV{GITALIST_REPO_DIR} = '';
     use_ok 'Catalyst::Test', 'Gitalist';
 }
+use TestGitalist;
 
 for my $p ('', qw/ repo1 nodescription bare.git opml /) {
     my $path = '/' . $p;
@@ -51,22 +53,3 @@ like $response->content, qr/Page not found/, 'invalid repository handled correct
 }
 
 done_testing;
-
-sub test_uri {
-    my ($uri, $qs) = @_;
-    $qs ||= '';
-    my $request = "/$uri"; 
-    $request .= "?$qs" if defined $qs;
-    my $response = request($request);
-    ok($response->is_success, "ok $uri - $qs");
-    return $response;
-}
-
-sub curry_test_uri {
-    my $prefix = shift;
-    my $to_curry = shift || \&test_uri;
-    sub {
-        my $uri = shift;
-        $to_curry->("$prefix/$uri", @_);
-    };
-}
index 3017ef7..1273bfb 100644 (file)
@@ -3,6 +3,7 @@ use strict;
 use warnings;
 use Test::More;
 use FindBin qw/$Bin/;
+use lib "$Bin/lib";
 
 BEGIN {
     $ENV{GITALIST_CONFIG} = $Bin;
@@ -11,6 +12,7 @@ BEGIN {
     use warnings;
     use_ok 'Catalyst::Test', 'Gitalist';
 }
+use TestGitalist;
 
 ok( request('/')->is_success, 'Request should succeed' );
 
@@ -249,18 +251,3 @@ test('/', 'a=blame;f=file1;hb=3f7567c7bdf7e7ebf410926493b92d398333116e');
 
 done_testing;
 
-sub test_uri {
-    my ($p, $uri, $qs) = @_;
-    $qs ||= '';
-    my $request = "$uri?p=repo1;$qs";
-    my $response = request($request);
-    ok($response->is_success, "ok $request");
-}
-
-sub curry_test_uri {
-    my $p = shift;
-    sub {
-        my ($uri, $qs) = @_;
-        test_uri($p, $uri, $qs);
-    };
-};
diff --git a/t/lib/TestGitalist.pm b/t/lib/TestGitalist.pm
new file mode 100644 (file)
index 0000000..05422de
--- /dev/null
@@ -0,0 +1,47 @@
+package TestGitalist;
+use strict;
+use warnings;
+use Exporter qw/import/;
+use Catalyst::Test qw/Gitalist/;
+use Test::More;
+
+our @EXPORT = qw/
+    test_uri
+    curry_test_uri
+/;
+
+use constant ();
+BEGIN {
+    my $mech = eval {
+        require Test::WWW::Mechanize::Catalyst;
+        Test::WWW::Mechanize::Catalyst->new(catalyst_app => 'Gitalist')
+    };
+    constant->import('MECH', $mech );
+}
+
+sub test_uri {
+    my ($uri, $qs) = @_;
+    $qs ||= '';
+    my $request = "/$uri"; 
+    $request .= "?$qs" if defined $qs;
+    my $response = request($request);
+    ok($response->is_success, "ok $uri - $qs");
+    if (MECH) {
+        my $res = MECH()->get($request);
+        ok $res->is_success, "ok mech $uri - $qs (" . $res->code . ')';
+        MECH()->page_links_ok()
+            if $res->content_type =~ m|text/html|;
+    }
+    return $response;
+}
+
+sub curry_test_uri {
+    my $prefix = shift;
+    my $to_curry = shift || \&test_uri;
+    sub {
+        my $uri = shift;
+        $to_curry->("$prefix/$uri", @_);
+    };
+}
+
+1;