Merge commit 'v7.10.18' into 8

Conflicts:
	docs/gotcha.txt
	docs/previousVersion.sql
	docs/templates.txt
	lib/WebGUI.pm
	lib/WebGUI/Asset/File.pm
	lib/WebGUI/Asset/Story.pm
	lib/WebGUI/Asset/Wobject/Calendar.pm
	lib/WebGUI/Asset/Wobject/Thingy.pm
	lib/WebGUI/AssetExportHtml.pm
	lib/WebGUI/Content/AssetManager.pm
	lib/WebGUI/Group.pm
	lib/WebGUI/Macro/AssetProxy.pm
	lib/WebGUI/Shop/PayDriver/PayPal/PayPalStd.pm
	lib/WebGUI/Storage.pm
	t/Asset/AssetExportHtml.t
	t/Asset/Story.t
	t/Shop/TaxDriver/Generic.t
	t/Storage.t
This commit is contained in:
Doug Bell 2011-06-21 16:03:49 -05:00
commit 0c5acb697b
75 changed files with 979 additions and 139 deletions

View file

@ -882,6 +882,7 @@ sub getTitleTests {
subtest 'canAdd tolerates being called as an object method', sub {
my $class = 'WebGUI::Asset::Snippet';
my $snip = $tempNode->addChild({className => $class});
WebGUI::Test->addToCleanup($snip);
# Make a test user who's just in Turn Admin On
my $u = WebGUI::User->create($session);

View file

@ -20,6 +20,7 @@ use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;
use WebGUI::Asset;
use WebGUI::Exception;
use WebGUI::Test::Event;
use Cwd;
use Exception::Class;
@ -36,7 +37,27 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
plan tests => 128; # Increment this number for each test you create
WebGUI::Test->originalConfig('exportPath');
my @events;
my $testRan = 1;
plan tests => 125; # Increment this number for each test you create
sub export_ok {
my ($asset, $message) = @_;
subtest $message => sub {
plan tests => 3;
my $e;
my @events = trap {
eval { $asset->exportWriteFile() };
$e = $@;
} $asset->session, 'asset::export';
ok !$e, 'ran without exception';
is scalar @events, 1, 'event fired once';
is $events[0][2], $asset->exportGetUrlAsPath->absolute;
};
}
#----------------------------------------------------------------------------
# exportCheckPath()
@ -385,11 +406,7 @@ my $content;
my $guid = $session->id->generate;
my $guidPath = Path::Class::Dir->new($config->get('uploadsPath'), 'temp', $guid);
$config->set('exportPath', $guidPath->absolute->stringify);
eval { $parent->exportWriteFile() };
is($@, '', "exportWriteFile works when creating exportPath");
# ensure that the file was actually written
ok(-e $parent->exportGetUrlAsPath->absolute->stringify, "exportWriteFile actually writes the file when creating exportPath");
export_ok $parent, 'exportWriteFile works when creating exportPath';
# now make sure that it contains the correct content
$content = WebGUI::Test->getPage2(
@ -444,7 +461,7 @@ eval { $firstChild->exportWriteFile() };
is($@, '', "exportWriteFile works for first_child");
# ensure that the file was actually written
ok(-e $firstChild->exportGetUrlAsPath->absolute->stringify, "exportWriteFile actually writes the first_child file");
export_ok $firstChild, 'exportWriteFile works for first_child';
# verify it has the correct contents
eval { $content = WebGUI::Test->getPage2( $firstChild->get('url').'?func=exportHtml_view', ) };
@ -456,11 +473,7 @@ $guidPath->rmtree;
$session->response->setNoHeader(1);
$session->user( { userId => 1 } );
eval { $grandChild->exportWriteFile() };
is($@, '', "exportWriteFile works for grandchild");
# ensure that the file was written
ok(-e $grandChild->exportGetUrlAsPath->absolute->stringify, "exportWriteFile actually writes the grandchild file");
export_ok $grandChild, 'exportWriteFile works for grandchild';
# finally, check its contents
$session->style->sent(0);
@ -471,17 +484,12 @@ is(scalar $grandChild->exportGetUrlAsPath->absolute->slurp, $content, "exportWri
$guidPath->rmtree;
$asset = WebGUI::Asset->newById($session, 'ExportTest000000000001');
$session->response->setNoHeader(1);
eval { $asset->exportWriteFile() };
is($@, '', 'exportWriteFile for perl file works');
ok(-e $asset->exportGetUrlAsPath->absolute->stringify, "exportWriteFile actually writes the perl file");
export_ok $asset, 'exportWriteFile for perl file works';
$guidPath->rmtree;
$asset = WebGUI::Asset->newById($session, 'ExportTest000000000002');
eval { $asset->exportWriteFile() };
is($@, '', 'exportWriteFile for plain file works');
ok(-e $asset->exportGetUrlAsPath->absolute->stringify, "exportWriteFile actuall writes the plain file");
$asset = WebGUI::Asset->new($session, 'ExportTest000000000002');
export_ok $asset, 'exportWriteFile for plain file works';
$guidPath->rmtree;
@ -492,8 +500,11 @@ $guidPath->rmtree;
# permissions on something.
$parent->update( { groupIdView => 3 } ); # admins
$session->response->setNoHeader(1);
eval { $parent->exportWriteFile() };
$e = Exception::Class->caught();
@events = trap {
eval { $parent->exportWriteFile() };
$e = Exception::Class->caught();
} $session, 'asset::export';
isa_ok($e, 'WebGUI::Error', "exportWriteFile throws when user can't view asset");
cmp_deeply(
$e,
@ -507,6 +518,7 @@ cmp_deeply(
# no directory or file written
ok(!-e $parent->exportGetUrlAsPath->absolute->stringify, "exportWriteFile doesn't write file when user can't view asset");
ok(!-e $parent->exportGetUrlAsPath->absolute->parent, "exportWriteFile doesn't write directory when user can't view asset");
is scalar @events, 0, 'event not fired';
# undo our viewing changes
$parent->update( { groupIdView => 7 } ); # everyone

View file

@ -270,6 +270,7 @@ subtest 'asset metadata versioning' => sub {
is $meta->get(), 'version one', 'v1 has not been changed';
my $dup = $asset->duplicate;
WebGUI::Test->addToCleanup($dup);
my $db = $session->db;
my $count_rev = sub {

View file

@ -41,10 +41,10 @@ my $map = $node->addChild({
# Create a map point
my $test_point = {
website => 'http://www.plainblack.com',
address1 => '520 University Ave',
address1 => '520 University',
address2 => 'Suite 320',
city => 'Madison',
region => 'WI',
region => 'Wisconsin',
zipCode => '53703',
country => 'United States',
phone => '608-555-1212',

View file

@ -0,0 +1,50 @@
# vim:syntax=perl
#-------------------------------------------------------------------
# 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
#------------------------------------------------------------------
=head1 BUG DESCRIPTION
Thread's duplicate method fails if the subscriptionGroupId isn't a valid group
(for instance, if it was imported from another site). It should just not copy
the group in that case.
=cut
use warnings;
use strict;
use Test::More tests => 4;
use Test::Exception;
use FindBin;
use lib "$FindBin::Bin/../../../lib";
use WebGUI::Test;
use WebGUI::Asset;
my $session = WebGUI::Test->session;
my $collab = WebGUI::Test->asset( className => 'WebGUI::Asset::Wobject::Collaboration' );
my $thread = $collab->addChild(
{
className => 'WebGUI::Asset::Post::Thread',
subscriptionGroupId => $session->id->generate(),
}
);
WebGUI::Test->addToCleanup($thread);
SKIP: {
my $copy;
skip('duplicate died', 3) unless
lives_ok { $copy = $thread->duplicate() } q"duplicate() doesn't die";
WebGUI::Test->addToCleanup($copy);
my $groupId = $copy->get('subscriptionGroupId');
ok $groupId, 'Copy has a group id';
isnt $groupId, $thread->get('subscriptionGroupId'), '...a different one';
ok(WebGUI::Group->new($session, $groupId), '...and it instantiates');
};

View file

@ -26,6 +26,10 @@ my %tag = ( tagId => $versionTag->getId, status => "pending" );
addToCleanup($versionTag);
my $snippet = $node->addChild({className=>'WebGUI::Asset::Snippet', %tag});
# Make sure TemplateToolkit is in the config file
WebGUI::Test->originalConfig( 'templateParsers' );
$session->config->addToArray( 'templateParsers' => 'WebGUI::Asset::Template::TemplateToolkit' );
# Test for a sane object type
isa_ok($snippet, 'WebGUI::Asset::Snippet');

View file

@ -8,6 +8,9 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use Test::MockTime qw/:all/;
use FindBin;
use strict;
use WebGUI::Test;
@ -77,8 +80,9 @@ WebGUI::Test->addToCleanup($storage1, $storage2);
#
############################################################
my $tests = 45;
plan tests => 1 + $tests
my $tests = 48;
plan tests => 1
+ $tests
+ $canEditMaker->plan
;
@ -459,4 +463,61 @@ cmp_bag(
) or diag Dumper( $keyword_loop );
$session->scratch->delete('isExporting');
############################################################
#
# addRevision, copying and duplicating photo data
#
############################################################
set_relative_time(-70);
my $rev_story = $archive->addChild({
className => 'WebGUI::Asset::Story',
title => 'Story revision',
subtitle => 'The story of a CMS',
byline => 'C.F. Kuskie',
story => 'Revisioning a story should not cause the photo information to be lost.',
}, undef, undef, { skipAutoCommitWorkflows => 1, skipNotification => 1, });
my $tag = WebGUI::VersionTag->getWorking($session);
$tag->commit;
my $rev_story = $rev_story->cloneFromDb;
my $rev_storage = WebGUI::Storage->create($session);
$rev_story->setPhotoData([{
byLine => 'C Forest Kuskie',
caption => 'ugly old hacker',
storageId => $rev_storage->getId,
}]);
cmp_deeply(
$rev_story->getPhotoData,
[{
byLine => 'C Forest Kuskie',
caption => 'ugly old hacker',
storageId => $rev_storage->getId,
}],
'setup for add revision test, photo data'
);
restore_time();
my $revision = $rev_story->addRevision({}, undef, undef, { skipAutoCommitWorkflows => 1, skipNotification => 1, });
cmp_deeply(
$revision->getPhotoData,
[{
byLine => 'C Forest Kuskie',
caption => 'ugly old hacker',
storageId => ignore(),
}],
'revision has a copy of most of the photo data'
);
my $revision_storageId = $revision->getPhotoData->[0]->{storageId};
ok($revision_storageId && ($revision_storageId ne $rev_storage->getId), 'storageId in the revision is different from the original');
#vim:ft=perl

View file

@ -55,7 +55,7 @@ use Data::Dumper;
use WebGUI::Asset::Wobject::Calendar;
use WebGUI::Asset::Event;
plan tests => 12 + scalar @icalWrapTests;
plan tests => 14 + scalar @icalWrapTests;
my $session = WebGUI::Test->session;
@ -314,8 +314,6 @@ addToCleanup($tag2);
is(scalar @{ $windowCal->getLineage(['children'])}, 17, 'added events to the window calendar');
diag "startDate: ". $windowStart->toDatabase;
diag "endDate: ". $windowEnd->toDatabase;
my @window = $windowCal->getEventsIn($windowStart->toDatabase, $windowEnd->toDatabase);
cmp_bag(
@ -590,3 +588,13 @@ cmp_deeply(
[],
'getFeeds: returns an empty array ref with no feeds'
);
##Update with JSON and try again :)
$feedCal->update({icalFeeds => '[]'});
is_deeply $feedCal->get('icalFeeds'), [], 'set as JSON, returned perl';
cmp_deeply(
$feedCal->getFeeds(),
[],
'but getFeeds still returns a data structure.'
);