Changeset 577


Ignore:
Timestamp:
Apr 12, 2015, 2:33:25 PM (6 years ago)
Author:
kake
Message:

Make ->rename_node try to ensure a valid new node name (depending on formatter parameters).

Location:
wiki-toolkit/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wiki-toolkit/trunk/Changes

    r575 r577  
    1 0.84   23 February 2014
     10.85
     2        Make ->rename_node try to ensure a valid new node name (depending on
     3          formatter parameters).
     4
     50.84    23 February 2014
    26        Add new options to Lucy and Plucene backends: (1) content munging
    37          before search indexing, (2) total exclusion of certain nodes from
  • wiki-toolkit/trunk/lib/Wiki/Toolkit/Store/Database.pm

    r551 r577  
    723723    my $dbh = $self->dbh;
    724724    my $formatter = $wiki->{_formatter};
     725
     726    # For formatters that support it, run the new name through the node name
     727    # to param conversion and back again, to make sure any necessary munging
     728    # gets done.
     729    if ( $formatter->can( "node_name_to_node_param" )
     730         && $formatter->can( "node_param_to_node_name" ) ) {
     731        $new_name = $formatter->node_param_to_node_name(
     732                        $formatter->node_name_to_node_param( $new_name ) );
     733    }
    725734
    726735    my $timestamp = $self->_get_timestamp();
  • wiki-toolkit/trunk/t/040_rename.t

    r576 r577  
    77    plan skip_all => "no backends configured";
    88} else {
    9     plan tests => ( 35 * scalar @Wiki::Toolkit::TestLib::wiki_info );
     9    plan tests => ( 39 * scalar @Wiki::Toolkit::TestLib::wiki_info );
    1010}
    1111
     
    173173    is( 1, $anode3{'version'}, "no new version" );
    174174
    175     # Now with implicit and explicit
     175    # Ensure force_ucfirst_nodes is respected if and only if it's switched on.
     176    # Note that this isn't the same as the perl function ucfirst, which only
     177    # uppercases the first character of a string - it uppercases the first
     178    # character of each word.
     179    eval { require Wiki::Toolkit::Formatter::UseMod; };
     180    SKIP: {
     181        skip "Wiki::Toolkit::Formatter::UseMod not available", 4 if $@;
     182
     183        # First check with it on.
     184        $wiki->{_formatter} = Wiki::Toolkit::Formatter::UseMod->new(
     185            force_ucfirst_nodes => 1,
     186            munge_urls => 1,
     187        );
     188        $wiki->write_node( "Test Node", "A test node" )
     189            or die "Couldn't write Test Node";
     190        # "testing node" should be forced to "Testing Node"
     191        $wiki->rename_node( "Test Node", "testing node" );
     192        ok( $wiki->retrieve_node( "Testing Node" ),
     193            "New name for renamed node is forced ucfirst if we want it to be");
     194        ok( !$wiki->retrieve_node( "testing node" ),
     195            "... and the non-ucfirst name is not found" );
     196
     197        # And now check with it off.
     198        $wiki->{_formatter} = Wiki::Toolkit::Formatter::UseMod->new(
     199            force_ucfirst_nodes => 0,
     200            munge_urls => 1,
     201        );
     202        $wiki->write_node( "Test Node Two", "Another test node" )
     203            or die "Couldn't write Test Node Two";
     204        $wiki->rename_node( "Test Node Two", "testing node two" );
     205        ok( !$wiki->retrieve_node( "Testing Node Two" ),
     206            "New name for renamed node isn't forced ucfirst if we don't "
     207            . "want it to be" );
     208        ok( $wiki->retrieve_node( "testing node two" ),
     209            "... and the non-ucfirst name is found instead" );
     210    }
    176211}
Note: See TracChangeset for help on using the changeset viewer.