Fixed failing Content-Type tests.
Dan Brook [Thu, 6 May 2010 22:20:47 +0000 (23:20 +0100)]
* Fixed bare repo bug where we were trying to build references that
didn't exist.
* Fixed bug where HTML entities were creeping into the atom feed.

lib/Gitalist/Controller/Root.pm
lib/Gitalist/Git/Repository.pm
root/repository/atom.tt2
t/atom.t
t/json_view.t
t/opml.t
t/rss.t

index 4bbda7f..eb6a147 100644 (file)
@@ -79,8 +79,12 @@ sub error_404 : Action {
 __PACKAGE__->config(
     default => 'text/html',
     map => {
-        'text/html'        => [qw/ View Default /],
         'application/json' => [qw/ JSON /],
+        map { $_ => [qw/ View Default /] }
+            qw( text/css text/html text/plain
+                application/atom+xml application/rss+xml 
+                application/rss application/xml )
+
     }
 );
 
index 69c9051..74de771 100644 (file)
@@ -74,7 +74,7 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
                         lazy_build => 1 );
 
     method BUILD {
-        $self->$_() for qw/last_change owner description references/; # Ensure to build early.
+        $self->$_() for qw/last_change owner description /; # Ensure to build early.
     }
 
     ## Public methods
index 9f721ab..b3b2482 100644 (file)
@@ -4,7 +4,7 @@
   <modified>[% updated %]</modified>
   [% FOREACH Commit = Commits %]
   <entry>
-    <title>[% Commit.title | html_entity %]</title>
+    <title>[% Commit.title | xml %]</title>
     <id>[% Commit.id %]</id>
     <link rel="alternate" type="text/html" href="[% Commit.id %]" />
     <content type="xhtml">
index d4de77d..bb50e26 100644 (file)
--- a/t/atom.t
+++ b/t/atom.t
@@ -3,8 +3,9 @@ use FindBin qw/$Bin/;
 BEGIN { do "$FindBin::Bin/../script/env" or die $@ }
 use lib "$Bin/lib";
 use TestGitalist;
+use HTTP::Request::Common;
 
-my $res = request('/repo1/atom');
+my $res = request(GET 'http://localhost/repo1/atom', 'Content-Type' => 'application/atom+xml');
 ok $res->is_success;
 is $res->content_type, 'application/atom+xml';
 TODO: {
index b32a0a6..b4d683e 100644 (file)
@@ -28,15 +28,6 @@ is_deeply $data, {
           'is_bare' => 1,
           '__CLASS__' => 'Gitalist::Git::Repository',
           'last_change' => '2009-11-12T19:00:34Z',
-          'references' => {
-                            '0710a7c8ee11c73e8098d08f9384c2a839c65e4e' => [
-                                                                            'heads/branch1'
-                                                                          ],
-                            '36c6c6708b8360d7023e8a1649c45bcf9b3bd818' => [
-                                                                            'heads/master',
-                                                                            'tags/0.01'
-                                                                          ]
-                          },
           'name' => 'repo1',
           'description' => 'some test repository'
         };
index b5bb93c..642e709 100644 (file)
--- a/t/opml.t
+++ b/t/opml.t
@@ -3,8 +3,10 @@ use FindBin qw/$Bin/;
 BEGIN { do "$FindBin::Bin/../script/env" or die $@ }
 use lib "$Bin/lib";
 use TestGitalist;
+use HTTP::Request::Common;
+
+my $res = request(GET 'http://localhost/opml', 'Content-Type' => 'application/rss');
 
-my $res = request('/opml');
 ok $res->is_success;
 
 is $res->content_type, 'application/rss';
diff --git a/t/rss.t b/t/rss.t
index c9c3804..ee72240 100644 (file)
--- a/t/rss.t
+++ b/t/rss.t
@@ -3,8 +3,9 @@ use FindBin qw/$Bin/;
 BEGIN { do "$FindBin::Bin/../script/env" or die $@ }
 use lib "$Bin/lib";
 use TestGitalist;
+use HTTP::Request::Common;
 
-my $res = request('/repo1/rss');
+my $res = request(GET 'http://localhost/repo1/rss', 'Content-Type' => 'application/rss+xml');
 ok $res->is_success;
 is $res->content_type, 'application/rss+xml';
 like $res->content, qr{link>http://localhost/repo1</link};