|
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 | |
|---|
| 1 | use Wiki::Toolkit::Setup::SQLite; |
|---|
| 2 | use OpenGuides; |
|---|
| 3 | use OpenGuides::Test; |
|---|
| 4 | use Test::More; |
|---|
| 5 | |
|---|
| 6 | eval { require DBD::SQLite; }; |
|---|
| 7 | |
|---|
| 8 | if ( $@ ) { |
|---|
| 9 | my ($error) = $@ =~ /^(.*?)\n/; |
|---|
| 10 | plan skip_all => "DBD::SQLite could not be used - no database to test with ($error)"; |
|---|
| 11 | } |
|---|
| 12 | |
|---|
| 13 | plan tests => 2; |
|---|
| 14 | |
|---|
| 15 | Wiki::Toolkit::Setup::SQLite::cleardb( { dbname => "t/node.db" } ); |
|---|
| 16 | Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } ); |
|---|
| 17 | my $config = OpenGuides::Test->make_basic_config; |
|---|
| 18 | my $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 | |
|---|
| 23 | my $output = $guide->display_node( |
|---|
| 24 | id => "South Croydon Station", |
|---|
| 25 | return_output => 1, |
|---|
| 26 | ); |
|---|
| 27 | like( $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 | |
|---|
| 34 | like( $output, qr#Website:</span> <span class="url"><a href="http://longer.example.com/asdfasdf">http://longer.exampl...</a>#, "website correctly truncated" ); |
|---|