From eb978d87a480b55befbc544e06ed593d8808964f Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Wed, 29 Sep 2010 19:31:17 -0400 Subject: [PATCH] return the $sitemap object instead than the XML directly --- lib/Catalyst/Plugin/Sitemap.pm | 2 +- t/lib/TestApp/Controller/Root.pm | 12 ++++++------ t/sitemap.t | 10 ++++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/Catalyst/Plugin/Sitemap.pm b/lib/Catalyst/Plugin/Sitemap.pm index eb6e92b..7363950 100644 --- a/lib/Catalyst/Plugin/Sitemap.pm +++ b/lib/Catalyst/Plugin/Sitemap.pm @@ -61,7 +61,7 @@ sub sitemap { } - return $sitemap->xml; + return $sitemap; } 1; diff --git a/t/lib/TestApp/Controller/Root.pm b/t/lib/TestApp/Controller/Root.pm index 01a131d..0eb3c6e 100644 --- a/t/lib/TestApp/Controller/Root.pm +++ b/t/lib/TestApp/Controller/Root.pm @@ -8,20 +8,20 @@ use parent 'Catalyst::Controller'; sub sitemap : Path('/sitemap') { my ( $self, $c ) = @_; - $c->res->body( $c->sitemap ); + $c->res->body( $c->sitemap->xml ); } -sub alone :Path('/alone') :Sitemap { } +sub alone :Local :Sitemap { } -sub with_priority :Path('/with_priority') :Sitemap(0.75) { } +sub with_priority :Local :Sitemap(0.75) { } -sub with_function :Path('/with_function') :Sitemap(*) { } +sub with_function :Local :Sitemap(*) { } sub with_function_sitemap { - $_[2]->add( 'http://localhost/with_function' ); + $_[2]->add( 'http://localhost/root/with_function' ); } -sub with_args :Path('/with_args') +sub with_args :Local :Sitemap( lastmod => 2010-09-27, changefreq => daily ) {} diff --git a/t/sitemap.t b/t/sitemap.t index 26f91ab..10f3efe 100644 --- a/t/sitemap.t +++ b/t/sitemap.t @@ -10,16 +10,18 @@ use Catalyst::Test 'TestApp'; my $xml = request('/sitemap')->content; +diag $xml; + $xml =~ s/\s+//g; -like $xml, qr{http://localhost/alone}, ':Sitemap'; -like $xml, qr{http://localhost/with_function}, +like $xml, qr{http://localhost/root/alone}, ':Sitemap'; +like $xml, qr{http://localhost/root/with_function}, ':Sitemap(*)'; like $xml, - qr{http://localhost/with_priority0.75}, + qr{http://localhost/root/with_priority0.75}, ':Sitemap(0.75)'; like $xml, - qr{http://localhost/with_args2010-09-27daily}, + qr{http://localhost/root/with_args2010-09-27daily}, ':Sitemap(lotsa stuff)'; -- 2.45.2