Changeset 896


Ignore:
Timestamp:
Dec 9, 2006, 1:31:18 PM (15 years ago)
Author:
nick
Message:

Give a useful message if we try and set moderation on an unknown node

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/OpenGuides.pm

    r893 r896  
    12671267            print $output;
    12681268        } else {
    1269             $self->wiki->set_node_moderation(
     1269            my $worked = $self->wiki->set_node_moderation(
    12701270                                        name    => $node,
    12711271                                        required => $args{moderation_flag},
    1272                                     );
     1272                         );
     1273            my $moderation_flag = "changed";
     1274            unless($worked) {
     1275                $moderation_flag = "unknown_node";
     1276                warn("Tried to set moderation status on node '$node', which doesn't exist");
     1277            }
    12731278
    12741279            # Send back to the admin interface
     
    12761281            my $script_name = $self->config->script_name;
    12771282            my $q = CGI->new;
    1278             my $output = $q->redirect( $script_url.$script_name."?action=admin;moderation=changed" );
     1283            my $output = $q->redirect( $script_url.$script_name."?action=admin;moderation=".$moderation_flag );
    12791284            return $output if $return_output;
    12801285            print $output;
     
    15111516        if($args{moderation_completed} eq "changed") {
    15121517            $completed_action = "Node moderation flag changed";
     1518        }
     1519        if($args{moderation_completed} eq "unknown_node") {
     1520            $completed_action = "Node moderation flag not changed, node not known";
    15131521        }
    15141522    }
  • trunk/t/73_toggle_moderation.t

    r892 r896  
    33use OpenGuides;
    44use OpenGuides::Test;
    5 use Test::More tests => 12;
     5use Test::More tests => 14;
    66
    77eval { require DBD::SQLite; };
     
    99
    1010SKIP: {
    11     skip "DBD::SQLite not installed - no database to test with", 12
     11    skip "DBD::SQLite not installed - no database to test with", 14
    1212      unless $have_sqlite;
    1313
     
    112112    like($output, qr|Location: http://example.com/wiki.cgi\?action=admin;moderation=changed|, "Right location");
    113113    like($output, qr|Status: 302|, "Right status");
     114
     115    # And again, but this time with a made up node
     116    $output = $guide->set_node_moderation(
     117                                id => "THIS PAGE DOES NOT EXIST",
     118                                moderation_flag => 0,
     119                                password => $guide->config->admin_pass,
     120                                return_output => 1
     121    );
     122    like($output, qr|Location: http://example.com/wiki.cgi\?action=admin;moderation=unknown_node|, "Right location");
     123    like($output, qr|Status: 302|, "Right status");
    114124}
Note: See TracChangeset for help on using the changeset viewer.