Restore addAttachments and restoreAttachments to the 7.x series. In 8.x, the object property will act like an arrayref, so they won't be necessary. Fixes bug #11861.

This commit is contained in:
Colin Kuskie 2010-09-14 10:42:59 -07:00
parent 1131a5b4bc
commit 2eed74891a
3 changed files with 84 additions and 1 deletions

View file

@ -16,7 +16,7 @@ use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Asset::Template;
use Exception::Class;
use Test::More tests => 53; # increment this value for each test you create
use Test::More tests => 57; # increment this value for each test you create
use Test::Deep;
use Data::Dumper;
use Test::Exception;
@ -133,6 +133,34 @@ is($att4->[1]->{url}, 'bar', 'rev still has bar');
is($att4->[2]->{url}, 'baz', 'rev does have new thing') or diag( $template3rev->get('attachmentsJson') );
is(@$att4, 3, 'rev is proper size');
$template3rev->addAttachments([{ url => 'box', type => 'headScript', }, { url => 'bux', type => 'headScript', }, ]);
cmp_deeply(
[ map { $_->{url} } @{ $template3rev->getAttachments('headScript') } ],
[qw/foo bar baz box bux/],
'addAttachments appends to the end'
) or diag $template3rev->get('attachmentsJson');
$template3rev->removeAttachments(['box']);
cmp_deeply(
[ map { $_->{url} } @{ $template3rev->getAttachments('headScript') } ],
[qw/foo bar baz bux/],
'removeAttachments will remove urls by exact URL match'
) or diag $template3rev->get('attachmentsJson');
$template3rev->removeAttachments(['bu']);
cmp_deeply(
[ map { $_->{url} } @{ $template3rev->getAttachments('headScript') } ],
[qw/foo bar baz bux/],
'... checking that it is not treated like a wildcard'
) or diag $template3rev->get('attachmentsJson');
$template3rev->removeAttachments();
cmp_deeply(
[ map { $_->{url} } @{ $template3rev->getAttachments('headScript') } ],
[ ],
'... checking that all attachments are removed'
) or diag $template3rev->get('attachmentsJson');
$template3rev->purgeRevision();
## Check how templates in the trash and clipboard are handled.