Always get a fresh copy of the survey after doing revision control.

This commit is contained in:
Colin Kuskie 2010-06-11 19:11:12 -07:00
parent 1e55078ac0
commit 7df0cc51ed
2 changed files with 4 additions and 2 deletions

View file

@ -847,6 +847,7 @@ sub submitObjectEdit {
$survey = $self->addRevision;
$newVersionTag->commit();
$survey = $survey->cloneFromDb;
#Restore the old one, if it exists
$oldVersionTag->setWorking() if $oldVersionTag;

View file

@ -18,7 +18,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
plan tests => 47;
plan tests => 48;
#----------------------------------------------------------------------------
# put your tests here
@ -210,7 +210,7 @@ cmp_deeply(from_json($surveyEnd), { type => 'forward', url => '/getting_started'
is($session->db->quickScalar('select revisionDate from Survey where assetId = ?', [$surveyId]), $revisionDate, 'Revision unchanged');
# Push revisionDate into the past because we can't have 2 revision dates with the same epoch (this is very hacky)
$revisionDate--;
$revisionDate -= 5;
$session->stow->deleteAll();
$session->cache->clear;
$session->db->write('update Survey set revisionDate = ? where assetId = ?', [$revisionDate, $surveyId]);
@ -220,6 +220,7 @@ cmp_deeply(from_json($surveyEnd), { type => 'forward', url => '/getting_started'
$survey = WebGUI::Asset->newById($session, $surveyId);
isa_ok($survey, 'WebGUI::Asset::Wobject::Survey', 'Got back survey after monkeying with revisionDate');
is($session->db->quickScalar('select revisionDate from Survey where assetId = ?', [$surveyId]), $revisionDate, 'Revision date pushed back');
is($survey->revisionDate, $revisionDate, '... and in the object, too');
# Create new response
my $responseId = $survey->responseId;