Author: kake Date: 2012-04-20 16:20:42 +0100 (Fri, 20 Apr 2012) New Revision: 1363
Modified: trunk/lib/OpenGuides/Template.pm trunk/t/51_display_node.t Log: Made categories with numbers in sort correctly (not entirely sure why they weren't working before).
Modified: trunk/lib/OpenGuides/Template.pm =================================================================== --- trunk/lib/OpenGuides/Template.pm 2012-04-19 18:52:04 UTC (rev 1362) +++ trunk/lib/OpenGuides/Template.pm 2012-04-20 15:20:42 UTC (rev 1363) @@ -317,8 +317,8 @@ # a URL too. This is ick. my (@catlist, @loclist); if ( $args{metadata} ) { - @catlist = @{ $metadata{category} || [] }; - @loclist = @{ $metadata{locale} || [] }; + @catlist = sort @{ $metadata{category} || [] }; + @loclist = sort @{ $metadata{locale} || [] }; } else { my $categories_text = $q->param('categories'); my $locales_text = $q->param('locales');
Modified: trunk/t/51_display_node.t =================================================================== --- trunk/t/51_display_node.t 2012-04-19 18:52:04 UTC (rev 1362) +++ trunk/t/51_display_node.t 2012-04-20 15:20:42 UTC (rev 1363) @@ -13,7 +13,7 @@ plan skip_all => "DBD::SQLite could not be used - no database to test with ($error)"; }
-plan tests => 19; +plan tests => 20;
OpenGuides::Test::refresh_db();
@@ -121,3 +121,17 @@ unlike( $output, qr{\QLast edited}, "bogus last edited doesn't show up" ); like ( $output, qr{404 Not Found}, "404 status for empty node" ); + +# Make sure categories with numbers in are sorted correctly. Guess which pub +# I was in when I decided to finally fix this bug. +OpenGuides::Test->write_data( + guide => $guide, + node => "Dog And Bull", + categories => "GBG\r\nGBG2008\r\nGBG2011\r\nGBG2012\r\nGBG2007\r\nGBG2010\r\nGBG2009", + return_output => 1, + ); + +%tt_vars = $guide->display_node( id => "Dog And Bull", return_tt_vars => 1 ); +is_deeply( $tt_vars{category}, + [ qw( GBG GBG2007 GBG2008 GBG2009 GBG2010 GBG2011 GBG2012 ) ], + "categories with numbers in sorted correctly" );
openguides-commits@lists.openguides.org