Fixed two new Survey bugs
* Survey response startDate stored twice startDate was being stored both in a column in Survey_response and also inside the serialised responseJSON. Consolidated to column and moved startDate methods to Survey.pm where they are actually used. Was not causing errors because both copies were initialised to "now" at response creation time, and then never changed (this is also why we don't need any repair code to fix existing survey repsonses in the wild). * Survey ExpireIncompleteSurveyResponses Workflow Activity not enabled The only time you'd actually want to modify startDate is when you're trying to simulate response expiry in test code, which is why I found the above bug when I was writing the missing test suite for ExpireIncompleteSurveyResponses. Along with test suite, added upgrade code to enable workflow activity and add it to the Daily Maintenance Tasks workflow. Also made minor fixes to the workflow activity, such as making sure it uses the correct isComplete code.
This commit is contained in:
parent
0bfc16bf9a
commit
146373937d
9 changed files with 236 additions and 102 deletions
|
|
@ -18,7 +18,7 @@ my $session = WebGUI::Test->session;
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
my $tests = 42;
|
||||
my $tests = 45;
|
||||
plan tests => $tests + 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -73,6 +73,27 @@ is($survey->get('maxResponsesPerUser'), 1, 'maxResponsesPerUser defaults to 1');
|
|||
ok($survey->canTakeSurvey, '..which means user can take survey');
|
||||
is($survey->get('revisionDate'), $session->db->quickScalar('select revisionDate from Survey_response where Survey_responseId = ?', [$responseId]), 'Current revisionDate used');
|
||||
|
||||
####################################################
|
||||
#
|
||||
# startDate
|
||||
#
|
||||
####################################################
|
||||
|
||||
my $startDate = $survey->startDate;
|
||||
$survey->startDate($startDate + 10);
|
||||
is($survey->startDate, $startDate + 10, 'startDate get/set');
|
||||
|
||||
####################################################
|
||||
#
|
||||
# hasTimedOut
|
||||
#
|
||||
####################################################
|
||||
|
||||
ok(!$survey->hasTimedOut, 'Survey has not timed out');
|
||||
$survey->update( { timeLimit => 1 });
|
||||
$survey->startDate($startDate - 100);
|
||||
ok($survey->hasTimedOut, '..until we set timeLimit and change startDate');
|
||||
|
||||
# Complete Survey
|
||||
$survey->surveyEnd();
|
||||
|
||||
|
|
@ -249,7 +270,6 @@ like($storage->getFileContentsAsScalar($filename), qr{
|
|||
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ my $session = WebGUI::Test->session;
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
my $tests = 115;
|
||||
my $tests = 106;
|
||||
plan tests => $tests + 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -47,38 +47,6 @@ isa_ok($responseJSON , 'WebGUI::Asset::Wobject::Survey::ResponseJSON');
|
|||
|
||||
is($responseJSON->lastResponse(), -1, 'new: default lastResponse is -1');
|
||||
is($responseJSON->questionsAnswered, 0, 'new: questionsAnswered is 0 by default');
|
||||
cmp_ok((abs$responseJSON->startTime - $newTime), '<=', 2, 'new: by default startTime set to time');
|
||||
is_deeply( $responseJSON->responses, {}, 'new: by default, responses is an empty hashref');
|
||||
|
||||
my $now = time();
|
||||
my $rJSON = WebGUI::Asset::Wobject::Survey::ResponseJSON->new(buildSurveyJSON($session), qq!{ "startTime": $now }!);
|
||||
cmp_ok(abs($rJSON->startTime() - $now), '<=', 2, 'new: startTime set using JSON');
|
||||
|
||||
####################################################
|
||||
#
|
||||
# startTime
|
||||
#
|
||||
####################################################
|
||||
|
||||
$rJSON->startTime(780321600);
|
||||
is($rJSON->startTime, 780321600, 'startTime: set and get');
|
||||
|
||||
####################################################
|
||||
#
|
||||
# hasTimedOut
|
||||
#
|
||||
####################################################
|
||||
|
||||
##Reset for next set of tests
|
||||
$rJSON->startTime(time());
|
||||
|
||||
ok( ! $rJSON->hasTimedOut(1), 'hasTimedOut, not timed out, checked with 1 minute timeout');
|
||||
ok( ! $rJSON->hasTimedOut(0), 'hasTimedOut, not timed out, checked with 0 minute timeout');
|
||||
|
||||
$rJSON->startTime(time()-7200);
|
||||
ok( $rJSON->hasTimedOut(1), 'hasTimedOut, timed out');
|
||||
ok( ! $rJSON->hasTimedOut(0), 'hasTimedOut, bad limit');
|
||||
ok( ! $rJSON->hasTimedOut(4*60), 'hasTimedOut, limit check');
|
||||
|
||||
####################################################
|
||||
#
|
||||
|
|
@ -86,7 +54,7 @@ ok( ! $rJSON->hasTimedOut(4*60), 'hasTimedOut, limit check');
|
|||
#
|
||||
####################################################
|
||||
|
||||
$rJSON = WebGUI::Asset::Wobject::Survey::ResponseJSON->new(buildSurveyJSON($session), q!{}!);
|
||||
my $rJSON = WebGUI::Asset::Wobject::Survey::ResponseJSON->new(buildSurveyJSON($session), q!{}!);
|
||||
|
||||
#$rJSON->initSurveyOrder();
|
||||
cmp_deeply(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue