Changeset 6247


Ignore:
Timestamp:
02/08/10 10:36:26 (2 years ago)
Author:
AndrewJones
Message:

Item8480: Fix for setting the parent

Location:
trunk/TopicCreatePlugin
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/TopicCreatePlugin/data/System/TopicCreatePlugin.txt

    r6183 r6247  
    6868|  Plugin Version: | %$VERSION% | 
    6969|  Change&nbsp;History: | <!-- versions below in reverse order -->&nbsp; | 
     70|  08 Feb 2010: | v1.3: Foswikitask:Item8480 - Fix for setting the parent; Fix for using Macros as the parent in =%<nop>TOPICCREATE%= -- Foswiki:Main.AndrewJones | 
    7071|  28 Jan 2010: | v1.2: Foswikitask:Item8438 - =%<nop>TOPICCREATE%= now allows you to define a parent for the new topic -- Foswiki:Main.AndrewJones | 
    7172|  29 Sep 2009: | v1.1: Foswikitask:Item4757 - Fixed warning when using =%<nop>TOPICATTACH%= -- Foswiki:Main.AndrewJones | 
  • trunk/TopicCreatePlugin/lib/Foswiki/Plugins/TopicCreatePlugin.pm

    r6183 r6247  
    2626 
    2727our $VERSION = '$Rev$'; 
    28 our $RELEASE = '1.2'; 
     28our $RELEASE = '1.3'; 
    2929our $SHORTDESCRIPTION = 
    3030  'Automatically create a set of topics and attachments at topic save time'; 
  • trunk/TopicCreatePlugin/lib/Foswiki/Plugins/TopicCreatePlugin/Func.pm

    r6183 r6247  
    7878    $topicName = 
    7979      Foswiki::Func::expandCommonVariables( $topicName, $theTopic, $theWeb ); 
     80    $parent = 
     81      Foswiki::Func::expandCommonVariables( $parent, $theTopic, $theWeb ); 
    8082    $template = 
    8183      Foswiki::Func::expandCommonVariables( $template, $theTopic, $theWeb ); 
     
    109111 
    110112    # Set topic parent 
    111     $meta->putKeyed( 'TOPICPARENT', { name => $parent } ); 
     113    $meta->putAll( 'TOPICPARENT', { name => $parent } ); 
    112114 
    113115    # SMELL: replace with expandVariablesOnTopicCreation( $text ); 
  • trunk/TopicCreatePlugin/test/unit/TopicCreatePlugin/TopicCreateTests.pm

    r6183 r6247  
    7171} 
    7272 
    73 # test the use of %TOPICCREATE{ parent="WebHome" }% 
     73# test the use of %TOPICCREATE{ parent="FooBar" }% 
    7474sub test_parent { 
    7575    my $this = shift; 
     
    8181%META:TOPICPARENT{name="WebHome"}% 
    8282 
    83 %TOPICCREATE{template="$simpleTemplate" topic="$testTopic" parent="WebHome"}% 
     83%TOPICCREATE{template="$simpleTemplate" topic="$testTopic" parent="FooBar"}% 
     84 
     85HERE 
     86 
     87    Foswiki::Plugins::TopicCreatePlugin::beforeSaveHandler( $sampleText, 
     88        $this->{test_topic}, $this->{test_web} ); 
     89 
     90    # child topic should now exist 
     91    $this->assert( Foswiki::Func::topicExists( $this->{test_web}, $testTopic ), 
     92        "$testTopic was not created" ); 
     93 
     94    # parent of newly created topic should be WebHome 
     95    my ( $meta, undef ) = 
     96      Foswiki::Func::readTopic( $this->{test_web}, $testTopic ); 
     97    $this->assert_equals( "FooBar", $meta->getParent(), 
     98        "Parent of new child topic is incorrect" ); 
     99} 
     100 
     101# test the use of %TOPICCREATE{ parent="%HOMETOPIC%" }% 
     102sub test_parent_as_macro { 
     103    my $this = shift; 
     104 
     105    my $testTopic = "ParentTest2"; 
     106 
     107    my $sampleText = <<"HERE"; 
     108%META:TOPICINFO{author="guest" date="1053267450" format="1.0" version="1.35"}% 
     109%META:TOPICPARENT{name="WebHome"}% 
     110 
     111%TOPICCREATE{template="$simpleTemplate" topic="$testTopic" parent="%HOMETOPIC%"}% 
    84112 
    85113HERE 
     
    96124      Foswiki::Func::readTopic( $this->{test_web}, $testTopic ); 
    97125    $this->assert_equals( "WebHome", $meta->getParent(), 
    98         "Parent of new child topic is incorrect" ); 
     126"Parent of new child topic is incorrect. Should be the same as the current topic." 
     127    ); 
    99128} 
    100129 
Note: See TracChangeset for help on using the changeset viewer.