root/tags/rel0_59/t/45_home_recent_changes.t

Revision 956, 3.1 kB (checked in by earle, 22 months ago)

Complete transition to using skip_all (remove old SKIP blocks).
More verbose reporting for error "require"ing DBD::SQLite.

Line 
1use strict;
2use OpenGuides;
3use OpenGuides::Test;
4use Test::More;
5use Wiki::Toolkit::Setup::SQLite;
6
7eval { require DBD::SQLite; };
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 => 13;
14
15my ( $config, $guide, $wiki );
16
17# Clear out the database from any previous runs.
18unlink "t/node.db";
19unlink <t/indexes/*>;
20Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
21
22# Write some data to show up in recent changes.
23$config = OpenGuides::Test->make_basic_config;
24$guide = OpenGuides->new( config => $config );
25OpenGuides::Test->write_data(
26                              guide    => $guide,
27                              node     => "Red Lion",
28                              content  => "A pub.",
29                              username => "Kake",
30                              comment  => "I edited it.",
31                            );
32
33# First test that recent changes show up on the front page by default.
34$config = OpenGuides::Test->make_basic_config;
35$guide = OpenGuides->new( config => $config );
36
37my $output = $guide->display_node(
38                                   id            => $config->home_name,
39                                   return_output => 1,
40                                 );
41like( $output, qr/Red Lion/,
42      "recent changes show up on home page by default" );
43like( $output, qr/I edited it\./, "...including comments" );
44like( $output, qr/Kake/, "...and usernames" );
45like( $output, qr/Edit this page/, "...edit this page link is there too" );
46
47# And that they show up when we explicitly ask for them.
48$config = OpenGuides::Test->make_basic_config;
49$config->recent_changes_on_home_page( 1 );
50$guide = OpenGuides->new( config => $config );
51
52$output = $guide->display_node(
53                                   id            => $config->home_name,
54                                   return_output => 1,
55                                 );
56like( $output, qr/Red Lion/,
57      "recent changes show up on home page when we ask for them" );
58like( $output, qr/I edited it\./, "...including comments" );
59like( $output, qr/Kake/, "...and usernames" );
60like( $output, qr/Edit this page/, "...edit this page link is there too" );
61
62# And that they don't show up if we don't want them.  Turn off the navbar
63# too, since we want to make sure the edit page link shows up regardless (it
64# normally appears in the recent changes box).
65$config = OpenGuides::Test->make_basic_config;
66$config->recent_changes_on_home_page( 0 );
67$config->navbar_on_home_page( 0 );
68$guide = OpenGuides->new( config => $config );
69
70$output = $guide->display_node(
71                                   id            => $config->home_name,
72                                   return_output => 1,
73                                 );
74unlike( $output, qr/Red Lion/,
75      "recent changes don't show up on home page if we turn them off" );
76unlike( $output, qr/I edited it\./, "...comments not shown either" );
77unlike( $output, qr/Kake/, "...nor usernames" );
78unlike( $output, qr/Ten most.*recent changes/, "...heading not shown either" );
79like( $output, qr/Edit this page/, "...edit this page link is there though" );
Note: See TracBrowser for help on using the browser.