Changeset 1984
- Timestamp:
- 01/15/09 05:49:06 (3 years ago)
- Location:
- trunk/CommentPlugin
- Files:
-
- 3 edited
-
data/System/CommentPlugin.txt (modified) (1 diff)
-
lib/Foswiki/Plugins/CommentPlugin/Comment.pm (modified) (1 diff)
-
test/unit/CommentPlugin/CommentPluginTests.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/CommentPlugin/data/System/CommentPlugin.txt
r1952 r1984 249 249 | Plugin Version: | 13 Jan 2009 %$VERSION% | 250 250 | Change History: | | 251 | 15 Jan 2008 | Foswikitask:Item727 - data loss issue when missing anchor or location | 251 252 | 13 Jan 2009 | Foswikitask:736 Make !CommentPlugin aware of CompareRevisionsAddOn bin script. | 252 253 | 16 Dec 2008 | Foswiki version | -
trunk/CommentPlugin/lib/Foswiki/Plugins/CommentPlugin/Comment.pm
r1340 r1984 300 300 $inpost = 1; 301 301 } 302 } 303 #make sure the anchor or location exits 304 if (defined($location) and not($text =~ /(?<!location\=\")($location)/)) { 305 undef $location; 306 } 307 if (defined($anchor) and not($text =~ /^($anchor\s)/)) { 308 undef $anchor; 302 309 } 303 310 -
trunk/CommentPlugin/test/unit/CommentPlugin/CommentPluginTests.pm
r1340 r1984 66 66 $sattrs .= $anchor; 67 67 } 68 $sattrs .= '" ';68 $sattrs .= '" '; 69 69 } 70 70 … … 72 72 73 73 if ( $location ) { 74 $sattrs .= ' location="'.$location.'" ';74 $sattrs .= ' location="'.$location.'" '; 75 75 } 76 76 … … 78 78 $sattrs .= 'type="'.$type.'" '; 79 79 80 my $commentref = '%COMMENT{ type="'.$type.'"refmark="here"}%';80 my $commentref = '%COMMENT{'.$sattrs.' refmark="here"}%'; 81 81 82 82 # Build the target topic 83 83 my $sample = <<HERE; 84 84 TopOfTopic 85 %COMMENT{ type="$type"}%85 %COMMENT{$sattrs}% 86 86 HERE 87 87 if ($anchor ) { … … 205 205 $this->assert_matches(qr/$comm/, $text, "$web.$topic: $text"); 206 206 207 #uncomment this to debug what the actual output looks like. 208 #$this->assert_str_equals($sample, $text); 209 207 210 my $refexpr; 208 211 if ($anchor) { 209 212 $refexpr = $anchor; 210 213 } elsif ($location) { 211 $refexpr = "HereIsTheLocation";214 $refexpr = $location; 212 215 } else { 213 216 $refexpr = $commentref; … … 422 425 } 423 426 427 428 sub test_targetWebTopicAboveAnchor_Missing_Item727 { 429 my $this = shift; 430 431 my $sample = <<HERE; 432 before 433 %COMMENT{type="above" cols="100" target="%INCLUDINGTOPIC%#LatestComment"}% 434 after 435 HERE 436 $this->writeTopic($this->{test_web}, $this->{test_topic}, $sample); 437 my $pidx = 99; 438 my $html = 439 Foswiki::Plugins::CommentPlugin::Comment::_handleInput( 440 'remove="on"', 441 $this->{test_web}, 442 $this->{test_topic}, 443 \$pidx, 444 "The Message", 445 "", 446 "bottom"); 447 $this->assert_matches(qr/<input type="hidden" name="comment_remove" value="99"/, $html); 448 449 # Compose the query 450 my $comm = "This is the comment"; 451 my $query = new Unit::Request( 452 { 453 'comment_action' => 'save', 454 'comment_type' => 'above', 455 'comment' => $comm, 456 'comment_anchor' => '#LatestComment', 457 }); 458 $query->path_info("/$this->{test_web}/$this->{test_topic}"); 459 460 my $session = new Foswiki( $Foswiki::cfg{DefaultUserLoginName}, $query); 461 my $text = "Ignore this text"; 462 463 # invoke the save handler 464 $this->capture(\&Foswiki::UI::Save::save, $session ); 465 466 $text = Foswiki::Func::readTopicText($this->{test_web}, $this->{test_topic}); 467 # make sure it hasn't changed 468 $text =~ s/^%META.*?\n//gm; 469 $this->assert_str_equals(<<HERE, 470 before 471 472 473 This is the comment 474 475 -- TemporaryCommentPluginTestsUsersWeb.WikiGuest - 15 Jan 2009 476 %COMMENT{type="above" cols="100" target="%INCLUDINGTOPIC%#LatestComment"}% 477 after 478 HERE 479 $text); 480 } 481 482 483 sub test_targetWebTopicBelowAnchor_Missing_Item727 { 484 my $this = shift; 485 486 my $sample = <<HERE; 487 before 488 %COMMENT{type="below" target="%INCLUDINGTOPIC%#LatestComment"}% 489 after 490 HERE 491 $this->writeTopic($this->{test_web}, $this->{test_topic}, $sample); 492 my $pidx = 99; 493 my $html = 494 Foswiki::Plugins::CommentPlugin::Comment::_handleInput( 495 'remove="on"', 496 $this->{test_web}, 497 $this->{test_topic}, 498 \$pidx, 499 "The Message", 500 "", 501 "bottom"); 502 $this->assert_matches(qr/<input type="hidden" name="comment_remove" value="99"/, $html); 503 504 # Compose the query 505 my $comm = "This is the comment"; 506 my $query = new Unit::Request( 507 { 508 'comment_action' => 'save', 509 'comment_type' => 'below', 510 'comment' => $comm, 511 'comment_anchor' => '#LatestComment', 512 513 }); 514 $query->path_info("/$this->{test_web}/$this->{test_topic}"); 515 516 my $session = new Foswiki( $Foswiki::cfg{DefaultUserLoginName}, $query); 517 my $text = "Ignore this text"; 518 519 # invoke the save handler 520 $this->capture(\&Foswiki::UI::Save::save, $session ); 521 522 $text = Foswiki::Func::readTopicText($this->{test_web}, $this->{test_topic}); 523 # make sure it hasn't changed 524 $text =~ s/^%META.*?\n//gm; 525 $this->assert_str_equals(<<HERE, 526 before 527 %COMMENT{type="below" target="%INCLUDINGTOPIC%#LatestComment"}% 528 * This is the comment -- TemporaryCommentPluginTestsUsersWeb.WikiGuest - 15 Jan 2009 529 after 530 HERE 531 $text); 532 } 533 424 534 1;
Note: See TracChangeset
for help on using the changeset viewer.
