Remove autocommit from addRev in Story, because it committed the

story before the keywords were set, which messed up searching.
Adjust tests to request autocommit on all submitted stories.
This commit is contained in:
Colin Kuskie 2009-07-24 17:26:50 +00:00
parent 46db295296
commit 4226ef211f
5 changed files with 14 additions and 3 deletions

View file

@ -1,4 +1,5 @@
7.7.17
- fixed #10654: Story Archive: Search not working properly
7.7.16
- fixed #10590: Session::DateTime->secondsToInterval doesn't allow 7 weeks

View file

@ -78,7 +78,7 @@ sub addRevision {
my $newPhotoData = $newSelf->duplicatePhotoData;
$newSelf->setPhotoData($newPhotoData);
$newSelf->requestAutoCommit;
#$newSelf->requestAutoCommit;
return $newSelf;
}
@ -607,8 +607,8 @@ sub processPropertiesFromFormPost {
my $session = $self->session;
$self->next::method;
my $archive = delete $self->{_parent}; ##Force a new lookup.
$session->log->warn($self->getParent->get('className'));
$session->log->warn($self->getParent->getParent->get('className'));
#$session->log->warn($self->getParent->get('className'));
#$session->log->warn($self->getParent->getParent->get('className'));
my $form = $session->form;
##Handle old data first, to avoid iterating across a newly added photo.
my $photoData = $self->getPhotoData;
@ -824,6 +824,7 @@ Extend the superclass to make sure that the asset always stays hidden from navig
sub update {
my $self = shift;
my $properties = shift;
#$self->session->log->warn('story update');
return $self->next::method({%$properties, isHidden => 1});
}

View file

@ -130,6 +130,7 @@ is($story->get('isHidden'), 1, 'by default, stories are hidden');
$story->update({isHidden => 0});
is($story->get('isHidden'), 1, 'stories cannot be set to not be hidden');
is($story->get('state'), 'published', 'Story is published');
$story->requestAutoCommit;
{
##Version control does not alter the current object's status, fetch an updated copy from the

View file

@ -160,6 +160,7 @@ my $child = $archive->addChild({className => 'WebGUI::Asset::Wobject::StoryTopic
is($child, undef, 'addChild: Will only add Stories');
$child = $archive->addChild({className => 'WebGUI::Asset::Story', title => 'First Story'});
$child->requestAutoCommit;
isa_ok($child, 'WebGUI::Asset::Story', 'addChild added and returned a Story');
is($archive->getChildCount, 1, 'addChild: added it to the archive');
my $folder = $archive->getFirstChild();
@ -195,6 +196,7 @@ my ($yesterdayMorn,undef) = $session->datetime->dayStartEnd($yesterday);
my $story = $oldFolder->addChild({ className => 'WebGUI::Asset::Story', title => 'WebGUI is released', keywords => 'roger,foxtrot,echo'});
$creationDateSth->execute([$wgBday, $story->getId]);
$story->requestAutoCommit;
{
my $storyDB = WebGUI::Asset->newByUrl($session, $story->getUrl);
@ -203,6 +205,7 @@ $creationDateSth->execute([$wgBday, $story->getId]);
my $pastStory = $newFolder->addChild({ className => 'WebGUI::Asset::Story', title => "Yesterday is history" });
$creationDateSth->execute([$yesterday, $pastStory->getId]);
$pastStory->requestAutoCommit;
my $templateVars;
$templateVars = $archive->viewTemplateVariables();
@ -276,6 +279,9 @@ foreach my $storilet ($story2, $story3, $story4) {
$session->db->write("update asset set creationDate=$now where assetId=?",[$storilet->getId]);
}
$archive->update({storiesPerPage => 3});
$story2->requestAutoCommit;
$story3->requestAutoCommit;
$story4->requestAutoCommit;
##Don't assume that Admin and Visitor have the same timezone.
$session->user({userId => 3});

View file

@ -54,6 +54,7 @@ my $creationDateSth = $session->db->prepare('update asset set creationDate=? whe
my $pastStory = $newFolder->addChild({ className => 'WebGUI::Asset::Story', title => "Yesterday is history", keywords => 'andy,norton'});
$creationDateSth->execute([$yesterday, $pastStory->getId]);
$pastStory->requestAutoCommit;
my @staff = qw/norton hadley mert trout/;
my @inmates = qw/bogs red brooks andy heywood tommy jake skeet/;
@ -66,6 +67,7 @@ STORY: foreach my $name (@characters) {
my $namedStory = $nowFolder->addChild({ className => 'WebGUI::Asset::Story', title => $name, keywords => $name, } );
$storyHandler->{$name} = $namedStory;
$creationDateSth->execute([$now, $namedStory->getId]);
$namedStory->requestAutoCommit;
}
$storyHandler->{bogs}->update({subtitle => 'drinking his food through a straw'});