Changeset 341


Ignore:
Timestamp:
Aug 10, 2006, 4:26:52 PM (13 years ago)
Author:
nick
Message:

Add a friendly method for checking if a node requires moderation or not

Location:
wiki-toolkit/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wiki-toolkit/trunk/lib/Wiki/Toolkit.pm

    r338 r341  
    597597}
    598598
     599=item B<node_required_moderation>
     600
     601  my $needs = $wiki->node_required_moderation( "Wombat Defenestration" );
     602
     603Returns true if the node exists and requires moderation, and false otherwise.
     604
     605=cut
     606
     607sub node_required_moderation {
     608    my ($self, @args) = @_;
     609    my %node = $self->retrieve_node(@args);
     610
     611    # Return false if it doesn't exist
     612    unless(%node) { return 0; }
     613    unless($node{node_requires_moderation}) { return 0; }
     614
     615    # Otherwise return the state of the flag
     616    return $node{node_requires_moderation};
     617}
     618
    599619=item B<delete_node>
    600620
  • wiki-toolkit/trunk/t/021_moderation.t

    r289 r341  
    77    plan skip_all => "no backends configured";
    88} else {
    9     plan tests => ( 82 * scalar @Wiki::Toolkit::TestLib::wiki_info );
     9    plan tests => ( 85 * scalar @Wiki::Toolkit::TestLib::wiki_info );
    1010}
    1111
     
    208208        is( $node_data{content}, "No moderation", "Node should now be fifth version" );
    209209        is( $node_data{version}, "5", "Node should now be fifth version" );
     210
     211
     212    # Test that the shorthand node_required_moderation behaves
     213    is( 0, $wiki->node_required_moderation("MADE_UP"), "node_required_moderation behaves");
     214    is( 0, $wiki->node_required_moderation("Home"), "node_required_moderation behaves");
     215    is( 1, $wiki->node_required_moderation("Moderation"), "node_required_moderation behaves");
    210216}
Note: See TracChangeset for help on using the changeset viewer.