Author: ilmari Date: 2007-06-10 15:47:11 +0100 (Sun, 10 Jun 2007) New Revision: 1056
Modified: trunk/Changes trunk/lib/OpenGuides.pm trunk/t/51_display_node.t Log: Check for definedness of redirect parameter before defaulting to 1 (closes #104).
Modified: trunk/Changes =================================================================== --- trunk/Changes 2007-06-10 14:27:19 UTC (rev 1055) +++ trunk/Changes 2007-06-10 14:47:11 UTC (rev 1056) @@ -13,6 +13,7 @@ Support alternative database ports Only display the google maps preference if node maps are enabled (#192). + Respect redirect=0 (#104).
0.60 13 May 2007 Removed footer search from edit page (shouldn't have been there).
Modified: trunk/lib/OpenGuides.pm =================================================================== --- trunk/lib/OpenGuides.pm 2007-06-10 14:27:19 UTC (rev 1055) +++ trunk/lib/OpenGuides.pm 2007-06-10 14:47:11 UTC (rev 1056) @@ -175,7 +175,7 @@ my $wiki = $self->wiki; my $config = $self->config; my $oldid = $args{oldid} || ''; - my $do_redirect = $args{redirect} || 1; + my $do_redirect = defined($args{redirect}) ? $args{redirect} : 1;
my %tt_vars;
Modified: trunk/t/51_display_node.t =================================================================== --- trunk/t/51_display_node.t 2007-06-10 14:27:19 UTC (rev 1055) +++ trunk/t/51_display_node.t 2007-06-10 14:47:11 UTC (rev 1056) @@ -12,7 +12,7 @@ plan skip_all => "DBD::SQLite could not be used - no database to test with ($error)"; }
-plan tests => 7; +plan tests => 9;
Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } ); my $config = OpenGuides::Config->new( @@ -47,3 +47,14 @@ like( $output, qr{\Q<a href="wiki.cgi?action=edit;id=My_Home_Page"\E>Edit\s+this\s+page</a>}, "...and home page has an edit link" ); my %tt_vars = $guide->display_node( return_tt_vars => 1 ); ok( defined $tt_vars{recent_changes}, "...and recent_changes is set for the home node even if we have changed its name" ); + +$wiki->write_node( 'Redirect Test', '#REDIRECT Test Page', undef ); + +$output = $guide->display_node( id => 'Redirect Test', return_output => 1 ); + +like( $output, qr{^\QLocation: http://example.com/wiki.cgi?id=Test_Page;oldid=Redirect_Test%7Dms, + '#REDIRECT redirects correctly' ); + +$output = $guide->display_node( id => 'Redirect Test', return_output => 1, redirect => 0 ); + +unlike( $output, qr{^\QLocation: }ms, '...but not with redirect=0' );