root/trunk/t/59_preferences.t

Revision 1091, 2.2 kB (checked in by dom, 17 months ago)

Add noheaders option, and use that in preference to black content_type
arg. (fixes #220)

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
13eval { require DBD::SQLite; };
14if ( $@ ) {
15    plan skip_all => "DBD::SQLite not installed - no database to test with";
16    exit 0;
17}
18
19eval { require Test::HTML::Content; };
20if ( $@ ) {
21    plan skip_all => "Test::HTML::Content not installed";
22    exit 0;
23}
24
25plan tests => 2;
26
27Wiki::Toolkit::Setup::SQLite::cleardb( { dbname => "t/prefs.db" } );
28Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/prefs.db" } );
29my $config = OpenGuides::Test->make_basic_config;
30my $guide = OpenGuides->new( config => $config );
31my $wiki = $guide->wiki;
32
33$config->gmaps_api_key( "This is not a real API key." );
34$config->show_gmap_in_node_display( 1 );
35
36my $cookie = OpenGuides::CGI->make_prefs_cookie(
37                                                 config => $config,
38                                                 display_google_maps => 1,
39                                               );
40$ENV{HTTP_COOKIE} = $cookie;
41
42# If the google API is present and node maps are enabled, we should have the pref
43Test::HTML::Content::tag_ok( get_output($wiki, $config), 'input',
44                             { type => 'checkbox', name => 'display_google_maps' },
45                             'Google maps pref shown'
46                           );
47
48# But not if the node map is globally disabled
49$config->show_gmap_in_node_display( 0 );
50Test::HTML::Content::no_tag( get_output($wiki, $config), 'input',
51                             { type => 'checkbox', name => 'display_google_maps' },
52                             'No google maps prefs if node maps disabled'
53                           );
54
55sub get_output {
56    my ($wiki, $config) = @_;
57
58    return OpenGuides::Template->output(
59        wiki         => $wiki,
60        config       => $config,
61        template     => "preferences.tt",
62        noheaders    => 1,
63        vars         => {
64                          not_editable => 1,
65                          show_form    => 1
66                        },
67    );
68}
Note: See TracBrowser for help on using the browser.