change AssetHelpers to have short IDs instead of class names
This will make better code reuse: The Asset Manager will instead call the AssetHelper with the id of "cut" or "copy" to get the correct operation.
This commit is contained in:
parent
f249070c50
commit
b9e879b7aa
22 changed files with 156 additions and 115 deletions
|
|
@ -81,10 +81,10 @@ $mech->get('/'); # Start a session
|
|||
$mech->session->user({ userId => '3' });
|
||||
|
||||
# www_processAssetHelper
|
||||
$mech->get_ok( '/?op=admin;method=processAssetHelper;className=WebGUI::AssetHelper::Cut;assetId=' . $snip->getId );
|
||||
$mech->get_ok( '/?op=admin;method=processAssetHelper;helperId=cut;assetId=' . $snip->getId );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $mech->content ),
|
||||
WebGUI::AssetHelper::Cut->process( $snip ),
|
||||
WebGUI::AssetHelper::Cut->new( id => 'cut', session => $session )->process( $snip ),
|
||||
'www_processAssetHelper',
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -35,9 +35,10 @@ my $asset = WebGUI::Test->asset->addChild( {
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
# Check permissions
|
||||
my $helper = WebGUI::AssetHelper::ChangeUrl->new( id => 'change_url', session => $session );
|
||||
|
||||
$session->user({ userId => 1 });
|
||||
my $output = WebGUI::AssetHelper::ChangeUrl->process( $asset );
|
||||
my $output = $helper->process( $asset );
|
||||
ok( $output->{error}, "Errors on bad permissions" );
|
||||
|
||||
|
||||
|
|
@ -45,7 +46,7 @@ ok( $output->{error}, "Errors on bad permissions" );
|
|||
# Change URL!
|
||||
|
||||
$session->user({ userId => 3 }); # By the power of grayskull!
|
||||
my $output = WebGUI::AssetHelper::ChangeUrl->process( $asset );
|
||||
my $output = $helper->process( $asset );
|
||||
cmp_deeply( $output, {
|
||||
openDialog => all(
|
||||
re( 'method=changeUrl' ),
|
||||
|
|
|
|||
|
|
@ -36,16 +36,18 @@ plan tests => 3; # Increment this number for each test you create
|
|||
# put your tests here
|
||||
|
||||
my $output;
|
||||
my $helper = WebGUI::AssetHelper::Copy->new( id => 'copy', session => $session );
|
||||
my $home = WebGUI::Asset->getDefault($session);
|
||||
my $root = WebGUI::Asset->getRoot($session);
|
||||
|
||||
{
|
||||
|
||||
$output = WebGUI::AssetHelper::Copy->process($home);
|
||||
$output = $helper->process($home);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
openDialog => all(
|
||||
re('helperId=copy'),
|
||||
re('method=copy'),
|
||||
re('assetId=' . $home->getId ),
|
||||
),
|
||||
|
|
@ -55,7 +57,7 @@ my $root = WebGUI::Asset->getRoot($session);
|
|||
}
|
||||
|
||||
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
|
||||
$mech->get_ok( '/?op=assetHelper;className=WebGUI::AssetHelper::Copy;method=copy;assetId=' . $home->getId );
|
||||
$mech->get_ok( '/?op=assetHelper;helperId=copy;method=copy;assetId=' . $home->getId );
|
||||
|
||||
my $clippies = $root->getLineage(["descendants"], {statesToInclude => [qw{clipboard clipboard-limbo}], returnObjects => 1,});
|
||||
is @{ $clippies }, 1, '... only copied 1 asset to the clipboard, no children';
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ plan tests => 5; # Increment this number for each test you create
|
|||
# put your tests here
|
||||
|
||||
my $output;
|
||||
my $helper = WebGUI::AssetHelper::CopyBranch->new( id => 'copy_branch', session => $session );
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $root = WebGUI::Asset->getRoot( $session );
|
||||
my $tag = WebGUI::VersionTag->getWorking( $session );
|
||||
|
|
@ -60,11 +61,12 @@ addToCleanup( $tag );
|
|||
|
||||
{
|
||||
|
||||
$output = WebGUI::AssetHelper::CopyBranch->process($top);
|
||||
$output = $helper->process($top);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
openDialog => all(
|
||||
re('helperId=copy_branch'),
|
||||
re('method=getWith'),
|
||||
re('assetId=' . $top->getId ),
|
||||
),
|
||||
|
|
@ -74,7 +76,7 @@ addToCleanup( $tag );
|
|||
}
|
||||
|
||||
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
|
||||
$mech->get_ok( '/?op=assetHelper;className=WebGUI::AssetHelper::CopyBranch;method=copy;with=children;assetId=' . $top->getId );
|
||||
$mech->get_ok( '/?op=assetHelper;helperId=copy_branch;method=copy;with=children;assetId=' . $top->getId );
|
||||
WebGUI::Test->waitForAllForks;
|
||||
|
||||
my $clippies = $root->getLineage(["descendants"], {statesToInclude => [qw{clipboard clipboard-limbo}], returnObjects => 1,});
|
||||
|
|
@ -83,7 +85,7 @@ for my $asset ( @$clippies ) {
|
|||
$asset->purge;
|
||||
}
|
||||
|
||||
$mech->get_ok( '/?op=assetHelper;className=WebGUI::AssetHelper::CopyBranch;method=copy;with=descendants;assetId=' . $top->getId );
|
||||
$mech->get_ok( '/?op=assetHelper;helperId=copy_branch;method=copy;with=descendants;assetId=' . $top->getId );
|
||||
WebGUI::Test->waitForAllForks;
|
||||
my $clippies = $root->getLineage(["descendants"], {statesToInclude => [qw{clipboard clipboard-limbo}], returnObjects => 1,});
|
||||
is @{ $clippies }, 3, '... copied 3 asset to the clipboard';
|
||||
|
|
|
|||
|
|
@ -31,11 +31,12 @@ my $session = WebGUI::Test->session;
|
|||
# Tests
|
||||
|
||||
my $output;
|
||||
my $helper = WebGUI::AssetHelper::CreateShortcut->new( id => 'shortcut', session => $session );
|
||||
my $import = WebGUI::Asset->getImportNode($session);
|
||||
|
||||
my $priv_page = WebGUI::Test->asset( groupIdView => '3' );
|
||||
$session->user({userId => 1});
|
||||
$output = WebGUI::AssetHelper::CreateShortcut->process($priv_page);
|
||||
$output = $helper->process($priv_page);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
|
|
@ -48,7 +49,7 @@ $session->setting->set( versionTagMode => 'autoCommit' );
|
|||
$session->setting->set( skipCommitComments => '1' );
|
||||
$session->user({userId => 3});
|
||||
my $safe_page = WebGUI::Test->asset;
|
||||
$output = WebGUI::AssetHelper::CreateShortcut->process($safe_page);
|
||||
$output = $helper->process($safe_page);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,10 +31,11 @@ my $session = WebGUI::Test->session;
|
|||
# Tests
|
||||
|
||||
my $output;
|
||||
my $helper = WebGUI::AssetHelper::Cut->new( id => 'cut', session => $session );
|
||||
my $import = WebGUI::Asset->getImportNode($session);
|
||||
|
||||
$session->user({userId => 1});
|
||||
$output = WebGUI::AssetHelper::Cut->process($import);
|
||||
$output = $helper->process($import);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
|
|
@ -44,7 +45,7 @@ cmp_deeply(
|
|||
);
|
||||
|
||||
$session->user({userId => 3});
|
||||
$output = WebGUI::AssetHelper::Cut->process($import);
|
||||
$output = $helper->process($import);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
|
|
@ -54,7 +55,7 @@ cmp_deeply(
|
|||
);
|
||||
|
||||
my $safe_page = $import->getFirstChild;
|
||||
$output = WebGUI::AssetHelper::Cut->process($safe_page);
|
||||
$output = $helper->process($safe_page);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ my $session = WebGUI::Test->session;
|
|||
# Tests
|
||||
|
||||
my $output;
|
||||
my $helper = WebGUI::AssetHelper::EditBranch->new( id => 'edit_branch', session => $session );
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $root = WebGUI::Asset->getRoot( $session );
|
||||
my $top = $node->addChild({
|
||||
|
|
@ -54,7 +55,7 @@ WebGUI::Test->addToCleanup( $top, $child, $grand );
|
|||
|
||||
{
|
||||
|
||||
$output = WebGUI::AssetHelper::EditBranch->process($top);
|
||||
$output = $helper->process($top);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
|
|
@ -70,7 +71,7 @@ WebGUI::Test->addToCleanup( $top, $child, $grand );
|
|||
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
|
||||
$mech->get('/');
|
||||
$mech->session->user({ userId => 3 });
|
||||
$mech->get_ok( '/?op=assetHelper;className=WebGUI::AssetHelper::EditBranch;method=editBranch;assetId=' . $top->getId );
|
||||
$mech->get_ok( '/?op=assetHelper;helperId=edit_branch;method=editBranch;assetId=' . $top->getId );
|
||||
$mech->submit_form_ok({
|
||||
fields => {
|
||||
ownerUserId => '3',
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ my $session = WebGUI::Test->session;
|
|||
$session->user({ userId => 3 });
|
||||
|
||||
my $output;
|
||||
my $helper = WebGUI::AssetHelper::ExportHtml->new( id => 'export_html', session => $session );
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $root = WebGUI::Asset->getRoot( $session );
|
||||
my $top = $node->addChild({
|
||||
|
|
@ -62,7 +63,7 @@ WebGUI::Test->config->set( "exportPath" => $dir->dirname );
|
|||
|
||||
{
|
||||
|
||||
$output = WebGUI::AssetHelper::ExportHtml->process($top);
|
||||
$output = $helper->process($top);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
|
|
@ -78,7 +79,7 @@ WebGUI::Test->config->set( "exportPath" => $dir->dirname );
|
|||
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
|
||||
$mech->get('/');
|
||||
$mech->session->user({ userId => 3 });
|
||||
$mech->get_ok( '/?op=assetHelper;className=WebGUI::AssetHelper::ExportHtml;method=export;assetId=' . $top->getId );
|
||||
$mech->get_ok( '/?op=assetHelper;helperId=export_html;method=export;assetId=' . $top->getId );
|
||||
$mech->submit_form_ok({
|
||||
fields => {
|
||||
},
|
||||
|
|
|
|||
|
|
@ -45,8 +45,9 @@ my $newPage = $home->addChild({
|
|||
|
||||
$newPage = WebGUI::Asset->newById($session, $newPage->assetId);
|
||||
|
||||
my $helper = WebGUI::AssetHelper::Lock->new( id => 'lock', session => $session );
|
||||
$session->user({userId => 1});
|
||||
$output = WebGUI::AssetHelper::Lock->process($newPage);
|
||||
$output = $helper->process($newPage);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
|
|
@ -56,7 +57,7 @@ cmp_deeply(
|
|||
);
|
||||
|
||||
$session->user({userId => 3});
|
||||
$output = WebGUI::AssetHelper::Lock->process($newPage);
|
||||
$output = $helper->process($newPage);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
|
|
@ -70,7 +71,7 @@ ok $newPage->isLocked, 'Asset is locked, and ready for next test';
|
|||
is $newPage->getRevisionCount, 2, 'new revision added';
|
||||
|
||||
$session->user({userId => $editor->getId});
|
||||
$output = WebGUI::AssetHelper::Lock->process($newPage);
|
||||
$output = $helper->process($newPage);
|
||||
cmp_deeply(
|
||||
$output,
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue