source: trunk/t/54_redirect.t @ 392

Last change on this file since 392 was 392, checked in by kake, 17 years ago

Fix redirect bug.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.6 KB
Line 
1use strict;
2use CGI::Wiki::Setup::SQLite;
3use Config::Tiny;
4use OpenGuides;
5use Test::More tests => 2;
6
7eval { require DBD::SQLite; };
8my $have_sqlite = $@ ? 0 : 1;
9
10SKIP: {
11    skip "DBD::SQLite not installed - no database to test with", 2
12      unless $have_sqlite;
13
14    CGI::Wiki::Setup::SQLite::setup( { dbname => "t/node.db" } );
15    my $config = Config::Tiny->new;
16    $config->{_} = {
17                     dbtype             => "sqlite",
18                     dbname             => "t/node.db",
19                     indexing_directory => "t/indexes",
20                     script_name        => "wiki.cgi",
21                     script_url         => "http://example.com/",
22                     site_name          => "Test Site",
23                     template_path      => "./templates",
24                   };
25    my $guide = OpenGuides->new( config => $config );
26    my $wiki = $guide->wiki;
27
28    # Clear out the database from any previous runs.
29    foreach my $del_node ( $wiki->list_all_nodes ) {
30        $wiki->delete_node( $del_node ) or die "Can't delete $del_node";
31    }
32
33    $wiki->write_node( "Test Page", "#REDIRECT [[Test Page 2]]" )
34      or die "Can't write node";
35    $wiki->write_node( "Test Page 2", "foo" )
36      or die "Can't write node";
37    my $output = eval {
38        $guide->display_node( id => "Test Page", return_output => 1 );
39    };
40    is( $@, "", "->display_node doesn't die when page is a redirect" );
41
42    # Old versions of CGI.pm mistakenly print location: instead of Location:
43    like( $output,
44          qr/[lL]ocation: http:\/\/example.com\/wiki.cgi\?Test_Page_2/,
45          "...and redirects to the right place" );
46}
Note: See TracBrowser for help on using the repository browser.