root/trunk/t/68_bug_website_displayed.t

Revision 1231, 1.6 kB (checked in by dom, 3 months ago)

Correctly validate web site URLs during edit and display,
and truncate URLs that are too long (fixes #21)

Line 
1use Wiki::Toolkit::Setup::SQLite;
2use OpenGuides;
3use OpenGuides::Test;
4use Test::More;
5
6eval { require DBD::SQLite; };
7
8if ( $@ ) {
9    my ($error) = $@ =~ /^(.*?)\n/;
10    plan skip_all => "DBD::SQLite could not be used - no database to test with ($error)";
11}
12
13plan tests => 2;
14
15Wiki::Toolkit::Setup::SQLite::cleardb( { dbname => "t/node.db" } );
16Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
17my $config = OpenGuides::Test->make_basic_config;
18my $guide = OpenGuides->new( config => $config );
19
20$guide->wiki->write_node( "South Croydon Station", "A sleepy main-line station in what is arguably the nicest part of Croydon.", undef, { website => "http://example.com/" } ) or die "Couldn't write node";
21$guide->wiki->write_node( "North Croydon Station", "A busy main-line station in what is arguably the furthest North part of Croydon.", undef, { website => "http://longer.example.com/asdfasdf" } ) or die "Couldn't write node";
22
23my $output = $guide->display_node(
24                                     id => "South Croydon Station",
25                                     return_output => 1,
26                                 );
27like( $output, qr#Website:</span> <span class="url"><a href="http://example.com/">http://example.com/</a>#, "website correctly displayed" );
28
29$output = $guide->display_node(   
30                                    id => "North Croydon Station",
31                                    return_output => 1,
32                              );
33
34like( $output, qr#Website:</span> <span class="url"><a href="http://longer.example.com/asdfasdf">http://longer.exampl...</a>#, "website correctly truncated" );
Note: See TracBrowser for help on using the browser.