One-line fix for Survey ExpressionEngine bug that took over a day to find.

One of the file-scoped lexicals in ExpressionEngine wasn't being initialised,
which meant that tagged data was being cached across repeated engine runs
(including, would you believe, across modperl page requests).

The fix includes tests.
This commit is contained in:
Patrick Donelan 2009-11-05 22:09:23 -05:00 committed by Colin Kuskie
parent ec38f50de1
commit 804dbcfd26
3 changed files with 34 additions and 4 deletions

View file

@ -22,7 +22,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
my $tests = 58;
my $tests = 60;
plan tests => $tests + 1;
#----------------------------------------------------------------------------
@ -236,8 +236,34 @@ SKIP: {
{ jump => 'target', tags => {} }, 'external score resolves ok too' );
cmp_deeply( $e->run( $session, qq{jump {scoreX('$url', ext_s0) == 200} target}, {userId => $user->userId} ),
{ jump => 'target', tags => {} }, 'external score section totals work too' );
cmp_deeply( $e->run( $session, qq{jump {taggedX('$url', ext_tag, 1) == 199} target}, {userId => $user->userId} ),
cmp_deeply( $e->run( $session, qq{jump {taggedX('$url', ext_tag) == 199} target}, {userId => $user->userId} ),
{ jump => 'target', tags => {} }, 'external tag lookups work too' );
# Test for nasty bugs caused by file-scoped lexicals not being properly initialised in L<ExpressionEngine::run>
{
# Create a second test user
my $survey2 = WebGUI::Asset::Wobject::Survey->new($session, $survey->getId);
my $user2 = WebGUI::User->new( $session, 'new' );
WebGUI::Test->usersToDelete($user2);
$session->user({userId => $user2->userId});
my $responseId2 = $survey2->responseId( { userId => $user2->userId } );
my $rJSON2 = $survey2->responseJSON(undef, $responseId2);
$rJSON2->recordResponses({
'0-0-0' => 'My ext_s0q0a0 answer',
'0-1-0' => 'My ext_s0q1a0 answer',
});
$rJSON2->processExpression(q{ tag(ext_tag, 299) });
# Remember to persist our changes..
$survey2->persistSurveyJSON();
$survey2->persistResponseJSON();
$survey2->surveyEnd;
cmp_deeply( $e->run( $session, qq{jump {taggedX('$url', ext_tag) == 299} target}, {userId => $user2->userId} ),
{ jump => 'target', tags => {} }, 'external tag not cached' );
cmp_deeply( $e->run( $session, qq{jump {taggedX('$url', ext_tag) == 199} target}, {userId => $user->userId} ),
{ jump => 'target', tags => {} }, 'first external tag lookups still works' );
}
}
#----------------------------------------------------------------------------