Merge branch 'master' into WebGUI8. Merged up to 7.10.4

This commit is contained in:
Colin Kuskie 2010-11-03 09:47:36 -07:00
commit 5f3014aaee
66 changed files with 3078 additions and 997 deletions

View file

@ -17,6 +17,7 @@ use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Asset;
use WebGUI::VersionTag;
use Test::MockObject;
use Test::More; # increment this value for each test you create
plan tests => 29;
@ -147,12 +148,20 @@ sub copied {
return undef;
}
my @methods = qw(Single Children Descendants);
my $process = Test::MockObject->new->mock(update => sub {});
my @methods = (
# single duplicate doesn't fork, so we can just test the www method to
# make sure it gets it right
sub { shift->www_copy },
sub { shift->duplicateBranch(1, 'clipboard') },
sub { shift->duplicateBranch(0, 'clipboard') },
);
my @prefixes = qw(single children descendants);
for my $i (0..2) {
my $meth = "_wwwCopy$methods[$i]";
my $meth = $methods[$i];
$root->$meth();
my $clip = copied();
is_tree_of_folders($clip, $i+1, $meth);
is_tree_of_folders($clip, $i+1, @prefixes[$i]);
$clip->purge;
}

View file

@ -142,4 +142,13 @@ is ($event7->get('startDate'), '2000-09-01', 'startDate bumped by 1 day');
is ($event7->get('endTime'), '00:00:00', 'endTime set to 00:00:00 if the hour is more than 23');
is ($event7->get('endDate'), '2000-09-02', 'endDate bumped by 1 day');
#######################################
#
# duplicate
#
#######################################
my $event6b = $event6->duplicate();
isnt($event6b->get('storageId'), $event6->get('storageId'), 'duplicating an asset creates a new storage location');
done_testing;

View file

@ -0,0 +1,66 @@
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use FindBin;
use strict;
use lib "$FindBin::Bin/../../lib";
## The goal of this test is to test the link between the asset and its shortcut
# and that changes to the asset are propagated to the shortcut
use Scalar::Util qw( blessed );
use WebGUI::Test;
use WebGUI::Session;
use Test::More;
use WebGUI::Asset::Shortcut;
use WebGUI::Asset::Snippet;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
my $node = WebGUI::Asset->getImportNode($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Shortcut Test"});
WebGUI::Test->addToCleanup($versionTag);
# Make a snippet to shortcut
my $now = time();
my $snippet = $node->addChild({
className => "WebGUI::Asset::Snippet",
},
undef, $now-50);
my $shortcut = $node->addChild({
className => "WebGUI::Asset::Shortcut",
shortcutToAssetId => $snippet->getId,
},
undef, $now-10);
$versionTag->commit;
$session->db->write(q|update assetData set lastModified=? where assetId=?|,[WebGUI::Test->webguiBirthday, $snippet->getId]);
foreach my $asset ($snippet, $shortcut) {
$asset = $asset->cloneFromDb;
}
#----------------------------------------------------------------------------
# Tests
plan tests => 2;
is( $shortcut->getContentLastModified, $now-10, "getContentLastModified: returns date of shortcut since it has a newer revision date.");
$snippet->update({snippet => 'updated', }, $now-5);
diag $snippet->get('lastModified');
diag $snippet->getContentLastModified;
$shortcut = $shortcut->cloneFromDb; ##Wipe the cached version of the shortcut.
is( $shortcut->getContentLastModified, $snippet->get('lastModified'), "returns lastModified when shortcutted asset has a more recent date");

View file

@ -17,7 +17,7 @@ use Test::MockObject::Extends;
use WebGUI::Test;
use WebGUI::Test::MockAsset;
use WebGUI::Session;
use Test::More tests => 8; # increment this value for each test you create
use Test::More tests => 9; # increment this value for each test you create
use Test::Deep;
use Data::Dumper;
@ -126,6 +126,14 @@ cmp_deeply(
$session->request->setup_body({ });
$session->scratch->delete('userId');
################################################################
#
# getStatusList
#
################################################################
$board->update({statusList => "In\r\nOut\rHome\nLunch"});
is_deeply [$board->getStatusList], [qw(In Out Home Lunch)], 'getStatusList';
################################################################
#
# view

View file

@ -119,13 +119,37 @@ my $dt = DateTime->from_epoch(epoch => $now, time_zone => $session->datetime->ge
my $folderName = $dt->strftime('%B_%d_%Y');
$folderName =~ s/^(\w+_)0/$1/;
is($todayFolder->getTitle, $folderName, '... folder has the right name');
my $folderUrl = join '/', $archive->getUrl, lc $folderName;
is($todayFolder->getUrl, $folderUrl, '... folder has the right URL');
my $folderUrl = $archive->getFolderUrl($folderName);
is($todayFolder->get('url'), $folderUrl, '... folder has the right URL');
is($todayFolder->getParent->getId, $archive->getId, '... created folder has the right parent');
is($todayFolder->get('state'), 'published', '... created folder is published');
is($todayFolder->get('status'), 'approved', '... created folder is approved');
is($todayFolder->get('styleTemplateId'), $archive->get('styleTemplateId'), '... created folder has correct styleTemplateId');
{
my $undo = WebGUI::Test->overrideSetting(urlExtension => 'ext');
my $arch2 = $home->addChild({
className => $class,
title => 'Extension Tester',
});
addToCleanup($arch2);
is $arch2->get('url'),
'home/extension-tester.ext',
'ext added';
is $arch2->getFolderUrl('blah'),
'home/extension-tester/blah.ext',
'folder url: strip extension from parent and add to child';
my $folder = $arch2->getFolder($now);
ok defined $folder, 'getFolder with url extension';
is $folder->get('url'),
$arch2->getFolderUrl($folder->getMenuTitle),
'getFolderUrl and folder getUrl match';
}
my $sameFolder = $archive->getFolder($now);
is($sameFolder->getId, $todayFolder->getId, 'call with same time returns the same folder');
undef $sameFolder;