Merge branch 'master' of git@github.com:plainblack/webgui

Conflicts:

	docs/upgrades/upgrade_7.8.0-7.8.1.pl
This commit is contained in:
daviddelikat 2009-10-05 09:13:21 -05:00
commit f26d9f4570
78 changed files with 521 additions and 226 deletions

View file

@ -815,67 +815,83 @@ is($iufpAsset2->get('url'), 'inheriturlfromparent01/iufp2', '... update works pr
################################################################
#
# requestAutoCommit to move uncommitted child to uncommitted parent
# addRevision to uncommitted child of uncommitted parent
#
################################################################
my $versionTag5 = WebGUI::VersionTag->getWorking($session);
WebGUI::Test->tagsToRollback($versionTag5);
$versionTag5->set( { name => 'move commit of child to uncommitted parent on requestAutoCommit tests vt1' } );
$versionTag5->set( { name => 'move revision of uncommitted child to uncommitted parent tests vt1' } );
$properties = {
# '1234567890123456789012'
id => 'moveVersionToParent_01',
title => 'moveVersionToParent_01',
className => 'WebGUI::Asset::Wobject::Layout',
url => 'moveVersionToParent_01',
id => 'moveVersionToParent_01',
title => 'moveVersionToParent_01',
className => 'WebGUI::Asset::Wobject::Layout',
url => 'moveVersionToParent_01',
};
my $parentAsset = $defaultAsset->addChild($properties, $properties->{id});
my $parentVersionTag = WebGUI::VersionTag->new($session, $parentAsset->get('tagId'));
is($parentVersionTag->get('isCommitted'),0, 'built non-committed parent asset');
my $parentAsset = $defaultAsset->addChild( $properties, $properties->{id}, undef, { skipAutoCommitWorkflows => 1 } );
my $parentVersionTag = WebGUI::VersionTag->new( $session, $parentAsset->get('tagId') );
is( $parentVersionTag->get('isCommitted'), 0, 'built non-committed parent asset' );
my $versionTag6 = WebGUI::VersionTag->create($session, {});
WebGUI::Test->tagsToRollback($versionTag6);
$versionTag6->set( { name => 'move commit of child to uncommitted parent on requestAutoCommit tests vt2' } );
my $versionTag6 = WebGUI::VersionTag->create( $session, {} );
$versionTag6->set( { name => 'move revision of uncommitted child to uncommitted parent tests vt2' } );
$versionTag6->setWorking;
$properties2 = {
# '1234567890123456789012'
id => 'moveVersionToParent_03',
title => 'moveVersionToParent_03',
className => 'WebGUI::Asset::Wobject::Layout',
url => 'moveVersionToParent_03',
id => 'moveVersionToParent_03',
title => 'moveVersionToParent_03',
className => 'WebGUI::Asset::Wobject::Layout',
url => 'moveVersionToParent_03',
};
my $childAsset = $parentAsset->addChild($properties, $properties2->{id});
my $testAsset = WebGUI::Asset->newPending($session, $childAsset->get('parentId'));
my $testVersionTag = WebGUI::VersionTag->new($session, $testAsset->get('tagId'));
my $childAsset = $parentAsset->addChild(
$properties2, $properties2->{id},
time(),
{ skipAutoCommitWorkflows => 1 }
);
my $testAsset = WebGUI::Asset->newPending( $session, $childAsset->get('parentId') );
my $testVersionTag = WebGUI::VersionTag->new( $session, $testAsset->get('tagId') );
my $childVersionTag;
$childVersionTag = WebGUI::VersionTag->new($session, $childAsset->get('tagId'));
is($childVersionTag->get('isCommitted'),0, 'built non-committed child asset');
$childVersionTag = WebGUI::VersionTag->new( $session, $childAsset->get('tagId') );
is( $childVersionTag->get('isCommitted'), 0, 'built non-committed child asset' );
isnt($testAsset->get('tagId'),$childAsset->get('tagId'),'parent asset and child asset have different version tags');
isnt($testVersionTag->getId,$childVersionTag->getId,'parent asset and child asset version tags unmatched');
is( $testAsset->get('tagId'),
$childAsset->get('tagId'),
'uncommitted parent asset and uncommitted child asset have same version tag at addChild'
);
eval {
$childAsset->requestAutoCommit;
$childVersionTag = WebGUI::VersionTag->new($session, $childAsset->get('tagId'));
$properties2 = {
# '1234567890123456789012'
id => 'moveVersionToParent_03',
title => 'moveVersionToParent_03a',
className => 'WebGUI::Asset::Wobject::Layout',
url => 'moveVersionToParent_03a',
};
is($childVersionTag->get('isCommitted'),0, 'confirm non-committed child asset');
sleep 2;
$childAsset->addRevision( $properties2, time(), { skipAutoCommitWorkflows => 1 } );
is($testAsset->get('tagId'),$childAsset->get('tagId'),'parent asset and child asset have same version tags');
is( $parentVersionTag->get('isCommitted'), 0, 'confimr non-committed parent asset after revision' );
is( $childVersionTag->get('isCommitted'), 0, 'confirm non-committed child asset after revision' );
eval {
$testVersionTag->commit;
};
is( $testAsset->get('tagId'),
$childAsset->get('tagId'),
'uncommitted parent asset and uncommitted child asset have same version tag after addRevision'
);
is($testVersionTag->get('isCommitted'),1,'parent asset is now committed');
eval { $testVersionTag->commit; };
$childVersionTag = WebGUI::VersionTag->new($session, $childAsset->get('tagId'));
is($childVersionTag->get('isCommitted'),1,'child asset is now committed');
$session->log->warn('parent asset is now committed');
is( $testVersionTag->get('isCommitted'), 1, 'parent asset is now committed' );
$childVersionTag = WebGUI::VersionTag->new( $session, $childAsset->get('tagId') );
$session->log->warn('child asset is now committed');
is( $childVersionTag->get('isCommitted'), 1, 'child asset is now committed' );
################################################################
#

View file

@ -8,13 +8,6 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
# XXX I (chrisn) started this file to test the features I added to the
# Collaboration / Post system for 7.5, but didn't have the time available to me
# to do a full test suite for the Post Wobject. This means that this test suite
# is *largely incomplete* and should be finished. What is here *is* the
# following:
#
#
# 1. The basic framework for a test suite for the Post Asset.
# Includes setup, cleanup, boilerplate, etc. Basically the really boring,
# repetitive parts of the test that you don't want to write yourself.
@ -26,7 +19,7 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Session;
use Test::More tests => 9; # increment this value for each test you create
use Test::More tests => 16; # increment this value for each test you create
use WebGUI::Asset::Wobject::Collaboration;
use WebGUI::Asset::Post;
use WebGUI::Asset::Post::Thread;
@ -114,7 +107,11 @@ ok($post->canEdit(), "User in groupToEditPost group can edit post after the time
$session->user({userId => $groupIdEditUser->userId});
ok($post->canEdit(), "User in groupIdEditUserGroup group can edit post after the timeout");
######################################################################
#
# getSynopsisAndContent
#
######################################################################
my ($synopsis, $content) = $post->getSynopsisAndContent('', q|Brandheiße Neuigkeiten rund um's Klettern für euch aus der Region |);
is($synopsis, q|Brandheiße Neuigkeiten rund um's Klettern für euch aus der Region |, 'getSynopsisAndContent: UTF8 characters okay');
@ -132,9 +129,40 @@ is($synopsis, q|less than < greater than >|, '... HTML escaped characters
($synopsis, $content) = $post->getSynopsisAndContent('', q|<p>less than &lt; greater than &gt;</p>|);
is($synopsis, q|less than < greater than >|, '... HTML entities decoded by HTML::splitTag');
TODO: {
local $TODO = "Tests to make later";
ok(0, 'Whole lot more work to do here');
}
######################################################################
#
# getTemplateVars
#
######################################################################
my $versionTag2 = WebGUI::VersionTag->getWorking($session);
my $post1 = $collab->addChild({
className => 'WebGUI::Asset::Post::Thread',
content => 'hello, world!',
ownerUserId => 3,
}, @addArgs);
my $post2 = $collab->addChild({
className => 'WebGUI::Asset::Post::Thread',
content => 'hello, world!',
ownerUserId => 1,
}, @addArgs);
$versionTag2->commit();
WebGUI::Test->tagsToRollback($versionTag);
my $variables;
$session->user({userId => 1});
$variables = $post1->getTemplateVars();
is( $variables->{'ownerUserId'}, 3, 'first post owned by admin');
ok( $variables->{'hideProfileUrl'}, 'hide profile url, since current user is visitor');
$variables = $post2->getTemplateVars();
is( $variables->{'ownerUserId'}, 1, 'first post owned by admin');
ok( $variables->{'hideProfileUrl'}, 'hide profile url, since current user is visitor');
$session->user({userId => 3});
$variables = $post1->getTemplateVars();
is( $variables->{'ownerUserId'}, 3, 'first post owned by admin');
ok( !$variables->{'hideProfileUrl'}, 'show profile url');
$variables = $post2->getTemplateVars();
is( $variables->{'ownerUserId'}, 1, 'first post owned by admin');
ok( $variables->{'hideProfileUrl'}, 'hide profile url, since poster is visitor');
# vim: syntax=perl filetype=perl

View file

@ -25,6 +25,10 @@ use CSS::Packer;
use JavaScript::Packer;
use WebGUI::Asset::Template;
if ( !$ENV{CODE_COP} ) {
plan skip_all => "Set CODE_COP to enable these tests";
}
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
@ -32,6 +36,7 @@ my $templates = WebGUI::Asset->getRoot( $session )
->getLineage( ['descendants'], {
includeOnlyClasses => [ 'WebGUI::Asset::Template' ],
} );
WebGUI::Test->tagsToRollback( WebGUI::VersionTag->getWorking( $session ) );
#----------------------------------------------------------------------------
# Tests
@ -66,9 +71,4 @@ for my $templateId ( @$templates ) {
}
#----------------------------------------------------------------------------
# Cleanup
END {
WebGUI::VersionTag->getWorking( $session )->rollback;
}
#vim:ft=perl

View file

@ -0,0 +1,92 @@
# 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
#------------------------------------------------------------------
# Test the Collaboration system template variables
#
#
use FindBin;
use strict;
use lib "$FindBin::Bin/../../../lib";
use WebGUI::Test; # Must use this before any other WebGUI modules
use Test::More;
use Test::Deep;
use Data::Dumper;
use WebGUI::Session;
#----------------------------------------------------------------------------
# Tests
plan tests => 20; # Increment this number for each test you create
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
my @addChildArgs = ( {skipAutoCommitWorkflows=>1} );
my $collab = WebGUI::Asset->getImportNode( $session )->addChild({
className => 'WebGUI::Asset::Wobject::Collaboration',
threadsPerPage => 20,
displayLastReply => 1,
});
my @threads = (
$collab->addChild( {
className => 'WebGUI::Asset::Post::Thread',
title => "X - Foo",
isSticky => 0,
ownerUserId => 1,
}, undef, 1, @addChildArgs),
$collab->addChild( {
className => 'WebGUI::Asset::Post::Thread',
title => "X - Bar",
isSticky => 0,
ownerUserId => 3,
}, undef, 2, @addChildArgs),
);
$_->setSkipNotification for @threads; # 100+ messages later...
my $versionTag = WebGUI::VersionTag->getWorking( $session );
$versionTag->commit;
WebGUI::Test->tagsToRollback($versionTag);
my $templateVars;
my $posts;
$session->user({userId => 3});
$templateVars = $collab->getViewTemplateVars();
##Threads come in reverse order, most recent first
$posts = $templateVars->{post_loop};
is( $posts->[1]->{'ownerUserId'}, 1, 'first post owned by visitor');
ok( $posts->[1]->{'user.isVisitor'}, 'first post made by visitor');
ok( $posts->[1]->{'hideProfileUrl'}, 'hide profile url, since post made by visitor');
ok( $posts->[1]->{'lastReply.user.isVisitor'}, 'lastReply not made by visitor');
ok( $posts->[1]->{'lastReply.hideProfileUrl'}, 'lastReply show profile url, since post not made by visitor, and user is not visitor');
is( $posts->[0]->{'ownerUserId'}, 3, 'second post owned by admin');
ok( !$posts->[0]->{'user.isVisitor'}, 'first post made by visitor');
ok( !$posts->[0]->{'hideProfileUrl'}, 'show profile url, since post made by admin, and user is not visitor');
ok( !$posts->[0]->{'lastReply.user.isVisitor'}, 'lastReply not made by visitor');
ok( !$posts->[0]->{'lastReply.hideProfileUrl'}, 'lastReply show profile url, since post not made by visitor, and user is not visitor');
$session->user({userId => 1});
$templateVars = $collab->getViewTemplateVars();
##Threads come in reverse order, most recent first
$posts = $templateVars->{post_loop};
is( $posts->[1]->{'ownerUserId'}, 1, 'first post owned by visitor');
ok( $posts->[1]->{'user.isVisitor'}, 'first post made by visitor');
ok( $posts->[1]->{'hideProfileUrl'}, 'hide profile url, since current user is visitor');
ok( $posts->[1]->{'lastReply.user.isVisitor'}, 'lastReply not made by visitor');
ok( $posts->[1]->{'lastReply.hideProfileUrl'}, 'lastReply hide profile url, since user is visitor');
is( $posts->[0]->{'ownerUserId'}, 3, 'second post owned by admin');
ok( !$posts->[0]->{'user.isVisitor'}, 'first post made by visitor');
ok( $posts->[0]->{'hideProfileUrl'}, 'hide profile url, and user is visitor');
ok( !$posts->[0]->{'lastReply.user.isVisitor'}, 'lastReply not made by visitor');
ok( $posts->[0]->{'lastReply.hideProfileUrl'}, 'lastReply hide profile url, since user is visitor');
#vim:ft=perl

View file

@ -36,6 +36,12 @@ my $df = WebGUI::Asset->getImportNode( $session )
fieldConfiguration => '[]',
} );
my $dform = WebGUI::Asset->getDefault($session)->addChild({
className => "WebGUI::Asset::Wobject::DataForm",
mailData => 0,
});
$dform->createField('gotCaptcha', { type => 'Captcha', name => 'humanCheck', });
my $versionTag = WebGUI::VersionTag->getWorking($session);
WebGUI::Test->tagsToRollback($versionTag);
$versionTag->commit;
@ -43,7 +49,7 @@ $versionTag->commit;
#----------------------------------------------------------------------------
# Tests
plan tests => 1; # Increment this number for each test you create
plan tests => 4; # Increment this number for each test you create
#----------------------------------------------------------------------------
# _createForm
@ -60,4 +66,26 @@ $df->_createForm(
is($WebGUI::Test::logger_error, "Unable to load form control - MASSIVE FORM FAILURE", '_createForm logs when it cannot load a form type');
#----------------------------------------------------------------------------
# getContentLastModified
sleep 3;
$df->{_mode} = 'form';
is($df->getContentLastModified, $df->get('lastModified'), 'getContentLastModified: form normally returns lastModified');
$df->{_mode} = 'list';
cmp_ok(
$df->getContentLastModified,
'>',
$df->get('lastModified'),
'... form in list mode does not return lastModified'
);
$dform->{_mode} = 'form';
cmp_ok(
$dform->getContentLastModified,
'>',
$dform->get('lastModified'),
'... form with a captcha does not return lastModified, even in form mode'
);
#vim:ft=perl

View file

@ -18,18 +18,13 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
my $tests = 46;
plan tests => $tests + 1;
plan tests => 47;
#----------------------------------------------------------------------------
# put your tests here
my $usedOk = use_ok('WebGUI::Asset::Wobject::Survey');
my ($survey);
SKIP: {
skip $tests, "Unable to load Survey" unless $usedOk;
my $user = WebGUI::User->new( $session, 'new' );
WebGUI::Test->usersToDelete($user);
my $import_node = WebGUI::Asset->getImportNode($session);
@ -252,7 +247,6 @@ cmp_deeply(from_json($surveyEnd), { type => 'forward', url => '/getting_started'
is($survey->responseJSON->nextResponseSection()->{text}, 'new text', '..wheras the original response uses the original text');
}
}
# Test visualization
eval 'use GraphViz';
@ -314,3 +308,13 @@ cmp_deeply(
],
"Admin console submenu",
);
####################################################
#
# www_loadSurvey
#
####################################################
my $survey_json = $survey->www_loadSurvey({});
my $survey_data = JSON::from_json($survey_json);
unlike($survey_data->{edithtml}, qr/\^International/, 'www_loadSurvey process macros');

View file

@ -20,13 +20,12 @@ use Data::Dumper;
use WebGUI::Test;
use WebGUI::Session;
use Test::More tests => 19; # increment this value for each test you create
use Test::More tests => 20; # increment this value for each test you create
use WebGUI::Asset::Wobject::SyndicatedContent;
use XML::FeedPP;
my $session = WebGUI::Test->session;
my %var;
my (@rss_feeds);
##############################
## SETUP ##
@ -37,6 +36,7 @@ my $node = WebGUI::Asset->getImportNode($session);
# Create a version tag to work in
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"SyndicatedContent Test"});
WebGUI::Test->tagsToRollback($versionTag);
my $syndicated_content = $node->addChild({className=>'WebGUI::Asset::Wobject::SyndicatedContent'});
##############################
@ -106,8 +106,35 @@ cmp_ok(scalar(@{$var->{item_loop}}), '>', 0, 'the item loop has items');
my $processed_template = eval {$syndicated_content->processTemplate($var,undef,$template) };
ok($processed_template, "A response was received from processTemplate.");
END {
# Clean up after thy self
$versionTag->rollback();
}
####################################################################
#
# getTemplateVariables
#
####################################################################
##Construct a feed with no description, so the resulting template variables can
##be checked for an undef description
my $feed = XML::FeedPP->new(<<EOFEED);
<?xml version="1.0" encoding="UTF-8" ?>
<feed xmlns="http://purl.org/atom/ns#" version="0.3" xmlns:admin="http://webns.net/mvcb/" xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/">
<title type="text/plain">Revision Log - /WebGUI/</title>
<link rel="alternate" type="text/html" href="https://svn.webgui.org/svnweb/plainblack/log/WebGUI/" />
<author>
<name></name>
</author>
<modified>1970-01-01T00:53:41</modified>
<entry>
<title type="text/plain">12312 - Ready for 7.7.20 development.
</title>
<link rel="alternate" type="text/html" href="https://svn.webgui.org/svnweb/plainblack/revision?rev=12312" />
<author>
<name>colin</name>
</author>
<id>https://svn.webgui.org/svnweb/plainblack/revision?rev=12312</id>
<issued>1970-01-01T00:53:41</issued>
<modified>1970-01-01T00:53:41</modified>
</entry>
EOFEED
my $vars = $syndicated_content->getTemplateVariables($feed);
ok( defined $vars->{item_loop}->[0]->{description}, 'getTemplateVariables: description is not undefined');