Update the JSON collateral test. Duplicate JSONCollateral into a Role so it can be used with Assets.
This commit is contained in:
parent
b8fc033bd7
commit
9b071c1510
3 changed files with 319 additions and 43 deletions
|
|
@ -46,6 +46,8 @@ create table jsonCollateralDummy (
|
|||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
EOSQL
|
||||
|
||||
WebGUI::Test->addToCleanup(SQL => 'drop table jsonCollateralDummy');
|
||||
|
||||
plan tests => 40;
|
||||
|
||||
my $asset = WebGUI::Asset->getDefault($session)->addChild({
|
||||
|
|
@ -54,6 +56,7 @@ my $asset = WebGUI::Asset->getDefault($session)->addChild({
|
|||
});
|
||||
|
||||
my $tag = WebGUI::VersionTag->getWorking($session);
|
||||
WebGUI::Test->addToCleanup($tag);
|
||||
$tag->commit;
|
||||
|
||||
################################################################
|
||||
|
|
@ -97,7 +100,7 @@ cmp_deeply(
|
|||
#
|
||||
################################################################
|
||||
|
||||
my $assetClone = WebGUI::Asset->new($session, $asset->getId, 'WebGUI::Asset::JSONCollateralDummy');
|
||||
my $assetClone = $asset->cloneFromDb;
|
||||
|
||||
cmp_deeply(
|
||||
$assetClone->get('jsonField'),
|
||||
|
|
@ -344,13 +347,3 @@ cmp_deeply(
|
|||
'...collateral was removed'
|
||||
);
|
||||
|
||||
note $asset->getId;
|
||||
|
||||
|
||||
$tag->rollback;
|
||||
$asset->purge;
|
||||
|
||||
$session->db->write(<<EOSQL);
|
||||
drop table jsonCollateralDummy
|
||||
EOSQL
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,26 @@ use Tie::IxHash;
|
|||
use Class::C3;
|
||||
use base qw/WebGUI::JSONCollateral WebGUI::Asset/;
|
||||
|
||||
use strict;
|
||||
use Moose;
|
||||
use WebGUI::Definition::Asset;
|
||||
extends 'WebGUI::Asset';
|
||||
|
||||
define assetName => 'JSON Collateral Dummy';
|
||||
define tableName => 'jsonCollateralDummy';
|
||||
define icon => 'assets.gif';
|
||||
|
||||
property jsonField => (
|
||||
fieldType => 'textarea',
|
||||
noFormPost => 1,
|
||||
default => sub { [] },
|
||||
traits => ['Array', 'WebGUI::Definition::Meta::Property::Serialize',],
|
||||
isa => 'WebGUI::Type::JSONArray',
|
||||
coerce => 1,
|
||||
);
|
||||
|
||||
with 'WebGUI::Role::Asset::JSONCollateral';
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Asset::JSONCollateral
|
||||
|
|
@ -40,39 +60,7 @@ These methods are available from this class:
|
|||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( )
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my %properties;
|
||||
tie %properties, 'Tie::IxHash';
|
||||
%properties = (
|
||||
jsonField => {
|
||||
label => 'jsonField',
|
||||
hoverHelp => 'Not really needed, it is for internal data in this test case',
|
||||
fieldType => 'textarea',
|
||||
serialize => 1,
|
||||
defaultValue => [],
|
||||
noFormPost => 1,
|
||||
},
|
||||
);
|
||||
push(@{$definition}, {
|
||||
assetName=>'JSON Collateral Dummy',
|
||||
tableName=>'jsonCollateralDummy',
|
||||
autoGenerateForms=>1,
|
||||
className=>'WebGUI::Asset::JSONCollateralDummy',
|
||||
icon=>'assets.gif',
|
||||
properties=>\%properties
|
||||
}
|
||||
);
|
||||
return $class->next::method($session, $definition);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue