source: trunk/t/41_deletion.t @ 1243

Last change on this file since 1243 was 1243, checked in by Dominic Hargreaves, 13 years ago

Don't add delete links unless the user requests (fixes #159 - thanks bob)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.5 KB
Line 
1use strict;
2use OpenGuides;
3use OpenGuides::Template;
4use OpenGuides::Test;
5use OpenGuides::CGI;
6use Test::More tests => 3;
7
8my $config = OpenGuides::Test->make_basic_config;
9$config->site_name( "Test Site" );
10$config->script_url( "/" );
11
12my $guide = OpenGuides->new( config => $config );
13my $wiki = $guide->wiki;
14
15my $output = OpenGuides::Template->output(
16    wiki     => $wiki,
17    config   => $config,
18    template => "node.tt",
19);
20unlike( $output, qr/action=delete/,
21        "doesn't offer page deletion link by default" );
22$config->enable_page_deletion( "y" );
23    # set is_admin to 1
24my $cookie = OpenGuides::CGI->make_prefs_cookie(
25    config                     => $config,
26    username                   => "bob",
27    include_geocache_link      => 1,
28    preview_above_edit_box     => 1,
29    omit_help_links            => 1,
30    show_minor_edits_in_rc     => 1,
31    default_edit_type          => "tidying",
32    cookie_expires             => "never",
33    track_recent_changes_views => 1,
34    is_admin => 1,
35);
36$ENV{HTTP_COOKIE} = $cookie;
37
38$output = OpenGuides::Template->output(
39    wiki     => $wiki,
40    config   => $config,
41    template => "node.tt",
42);
43like( $output, qr/action=delete/,
44      "...but does when enable_page_deletion is set to 'y' and is_admin is 1" );
45$config->enable_page_deletion( 1 );
46$output = OpenGuides::Template->output(
47    wiki     => $wiki,
48    config   => $config,
49    template => "node.tt",
50);
51like( $output, qr/action=delete/,
52      "...and when enable_page_deletion is set to '1' and is_admin is 1" );
Note: See TracBrowser for help on using the repository browser.