Skip to content

Commit

Permalink
Item1308: give subroutine more conveying name; added unit test
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/branches/Release01x00@3153 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
ArthurClemens authored and ArthurClemens committed Mar 17, 2009
1 parent 42a2c75 commit 8ff9fb1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
2 changes: 1 addition & 1 deletion EditTablePlugin/lib/Foswiki/Plugins/EditTablePlugin.pm
Expand Up @@ -110,7 +110,7 @@ sub commonTagsHandler {
addViewModeHeadersToHead();
require Foswiki::Plugins::EditTablePlugin::Core;

Foswiki::Plugins::EditTablePlugin::Core::reinit();
Foswiki::Plugins::EditTablePlugin::Core::initInIncludedTopic();
Foswiki::Plugins::EditTablePlugin::Core::parseTables( $_[0], $_[1], $_[2] );
Foswiki::Plugins::EditTablePlugin::Core::process( $_[0], $_[1], $_[2],
$topic, $web );
Expand Down
6 changes: 5 additions & 1 deletion EditTablePlugin/lib/Foswiki/Plugins/EditTablePlugin/Core.pm
Expand Up @@ -81,7 +81,7 @@ Init variables again. If called from INCLUDE this is the first time we init
=cut

sub reinit {
sub initInIncludedTopic {
$preSp = '' unless $preSp;
getPreferencesValues();
}
Expand Down Expand Up @@ -607,6 +607,8 @@ s/$PATTERN_TABLE_ROW/handleTableRow( $1, $2, $tableNr, $isNewRow, $rowNr, $doEdi

=begin TML
Read preferences from plugin topic of preferences.
=cut

sub getPreferencesValues {
Expand Down Expand Up @@ -638,9 +640,11 @@ sub getPreferencesValues {
$prefDELETE_LAST_ROW_BUTTON = Foswiki::Func::getPreferencesValue(
"\U$pluginName\E_DELETE_LAST_ROW_BUTTON")
|| 'Delete last row';

$prefCANCEL_BUTTON =
Foswiki::Func::getPreferencesValue("\U$pluginName\E_CANCEL_BUTTON")
|| 'Cancel';

$prefMESSAGE_INCLUDED_TOPIC_DOES_NOT_EXIST =
Foswiki::Func::getPreferencesValue(
"\U$pluginName\E_INCLUDED_TOPIC_DOES_NOT_EXIST")
Expand Down
Expand Up @@ -1740,7 +1740,7 @@ THIS
my $viewUrlAuthTestTopic =
Foswiki::Func::getScriptUrl( $webName, $topicName, 'viewauth' );
my $viewUrlAuthOtherTopic =
Foswiki::Func::getScriptUrl( $webName, 'TopicToInclude', 'viewauth' );
Foswiki::Func::getScriptUrl( $webName, $includedTopic, 'viewauth' );
my $pubUrlSystemWeb =
Foswiki::Func::getUrlHost()
. Foswiki::Func::getPubUrlPath() . '/'
Expand Down Expand Up @@ -1794,6 +1794,59 @@ END

=pod
Includes a topic that has an EDITTABLE with param 'include' set: the table definition is in a third topic.
=cut

sub test_INCLUDE_include {
my $this = shift;

# Create topic with talbe definition
my $tableDefTopic = "QmsCommentTable";
Foswiki::Func::saveTopic( $this->{test_web}, $tableDefTopic, undef, <<THIS);
%EDITTABLE{ header="|* Section *|* Description *|* Severity *|* Status *|* Originator & Date *|" format="| text, 10 | textarea, 10x60 | select, 1, Major, Minor, Note | select, 1, Originated, Assessed, Performed, Rejected | text, 20 |" changerows="on" }%
THIS

my $includeTopic = "ProcedureSysarch000Comments";
Foswiki::Func::saveTopic( $this->{test_web}, $includeTopic, undef, <<THIS);
%EDITTABLE{ include="QmsCommentTable" }%
|*Section*|*Description*|*Severity*|*Status*|*Originator & Date*|
THIS

# include this in our test topic
my $topicName = $this->{test_topic};
my $webName = $this->{test_web};
my $viewUrlAuthTestTopic =
Foswiki::Func::getScriptUrl( $webName, $includeTopic, 'viewauth' );

my $viewUrlAuthOtherTopic =
Foswiki::Func::getScriptUrl( $webName, $includeTopic, 'viewauth' );

my $pubUrlSystemWeb =
Foswiki::Func::getUrlHost()
. Foswiki::Func::getPubUrlPath() . '/'
. $Foswiki::cfg{SystemWebName};

my $input = '%INCLUDE{"ProcedureSysarch000Comments"}%';

my $expected = <<END;
<div class="editTable">
<form name="edittable1_TemporaryEditTableFunctionsTestWebEditTableFunctions_TestTopicEditTableFunctions" action="$viewUrlAuthTestTopic#edittable1" method="post">
<input type="hidden" name="ettablenr" value="1" />
<input type="hidden" name="etedit" value="on" />
|*Section*|*Description*|*Severity*|*Status*|*Originator & Date*|
<input type="hidden" name="etrows" value="1" />
<input class="editTableEditImageButton" type="image" src="$pubUrlSystemWeb/EditTablePlugin/edittable.gif" alt="Edit this table" /> </form>
</div><!-- /editTable -->
END

my $result =
Foswiki::Func::expandCommonVariables( $input, $topicName, $webName );
$this->do_testHtmlOutput( $expected, $result, 0 );
}

=pod
Test if macro EDITCELL is preserved after saving
=cut
Expand Down

0 comments on commit 8ff9fb1

Please sign in to comment.