setting aside test for a bit to do some coding
This commit is contained in:
parent
50988eaa64
commit
3ed18c775b
7 changed files with 155 additions and 13 deletions
|
|
@ -164,7 +164,7 @@ sub definition {
|
|||
label => $EMS_i18n->get("location"),
|
||||
hoverHelp => $EMS_i18n->get("location help"),
|
||||
},
|
||||
relatedBadgeGroup => {
|
||||
relatedBadgeGroups => {
|
||||
tab => "properties",
|
||||
fieldType => "checkList",
|
||||
customDrawMethod=> 'drawRelatedBadgeGroupsField',
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ sub definition {
|
|||
label => $i18n->get("next submission id label"),
|
||||
hoverHelp => $i18n->get("next submission id label help")
|
||||
},
|
||||
canSubmitGroup => {
|
||||
canSubmitGroupId => {
|
||||
tab => "security",
|
||||
fieldType => "groupid",
|
||||
defaultValue => undef,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package WebGUI::Workflow::Activity::CleanupEMSSubmissions;
|
|||
use strict;
|
||||
use base 'WebGUI::Workflow::Activity';
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::International;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -50,8 +51,9 @@ sub definition {
|
|||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = WebGUI::International->new( $session, "Asset_EMSSubmissionForm" );
|
||||
push(@{$definition}, {
|
||||
name => "Cleanup EMS Submissions", # TODO internationalize
|
||||
name => $i18n->get("activity title cleanup submissions"),
|
||||
properties => {}
|
||||
});
|
||||
return $class->SUPER::definition($session,$definition);
|
||||
|
|
@ -70,7 +72,7 @@ sub execute {
|
|||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $root = WebGUI::Asset->getRoot($session);
|
||||
return $self->FAILED;
|
||||
return $self->ERROR;
|
||||
|
||||
my $sth = $session->db->read("select assetId from asset where className='WebGUI::Asset::Wobject::HelpDesk'");
|
||||
while (my ($assetId) = $sth->array) {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package WebGUI::Workflow::Activity::ProcessEMSApprovals;
|
|||
use strict;
|
||||
use base 'WebGUI::Workflow::Activity';
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::International;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -50,8 +51,9 @@ sub definition {
|
|||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = WebGUI::International->new( $session, "Asset_EMSSubmissionForm" );
|
||||
push(@{$definition}, {
|
||||
name => "Process Approved EMS Submissions", # TODO Internationalize
|
||||
name => $i18n->get("activity title approve submissions"),
|
||||
properties => {}
|
||||
});
|
||||
return $class->SUPER::definition($session,$definition);
|
||||
|
|
@ -70,7 +72,7 @@ sub execute {
|
|||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $root = WebGUI::Asset->getRoot($session);
|
||||
return $self->FAILED;
|
||||
return $self->ERROR;
|
||||
|
||||
my $sth = $session->db->read("select assetId from asset where className='WebGUI::Asset::Wobject::HelpDesk'");
|
||||
while (my ($assetId) = $sth->array) {
|
||||
|
|
|
|||
|
|
@ -59,6 +59,16 @@ our $I18N = { ##hashref of hashes
|
|||
lastUpdated => 1131394072,
|
||||
context => q|This help text is for the form description field. The user should be warned not to edit it unless they really know what they are doing.|
|
||||
},
|
||||
'activity title approve submissions' => {
|
||||
message => q|Process Approved EMS Submissions|,
|
||||
lastUpdated => 1131394072,
|
||||
context => q|This is the label used to describe the EMS submission approval activity|
|
||||
},
|
||||
'activity title cleanup submissions' => {
|
||||
message => q|Cleanup EMS Submissions|,
|
||||
lastUpdated => 1131394072,
|
||||
context => q|This is the label used to describe the EMS submission cleanup activity|
|
||||
},
|
||||
|
||||
# 'TODO' => {
|
||||
# message => q|TODO|,
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ my $session = WebGUI::Test->session;
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 200; # Increment this number for each test you create
|
||||
plan tests => 30; # Increment this number for each test you create
|
||||
|
||||
my $submitGroupA = WebGUI::Group->new($session,'new');
|
||||
my $submitGroupB = WebGUI::Group->new($session,'new');
|
||||
|
|
@ -123,6 +123,7 @@ my $frmA = $ems->addChild({
|
|||
className => 'WebGUI::Asset::EMSSubmissionForm',
|
||||
title => 'test A -- long',
|
||||
canSubmitGroup => $submitGroupA->getId,
|
||||
daysBeforeCleanup => 1,
|
||||
formDescription => q{ {
|
||||
'title' : { 'type' : 'text' },
|
||||
'description' : { 'type' : 'textarea' },
|
||||
|
|
@ -163,10 +164,10 @@ ok( $frmA->validateSubmission({
|
|||
}), 'valid submission: field value override by admin' );
|
||||
|
||||
|
||||
# TODO use meta field in this form
|
||||
my $frmB = $ems->addChild({
|
||||
className => 'WebGUI::Asset::EMSSubmissionForm',
|
||||
title => 'test B -- short',
|
||||
daysBeforeCleanup => 0,
|
||||
canSubmitGroup => $submitGroupB->getId,
|
||||
formDescription => q{ {
|
||||
'title' : { 'type' : 'text' },
|
||||
|
|
@ -198,7 +199,7 @@ isa_ok( $sub1, 'WebGUI::Asset::EMSSubmission', "valid submission succeeded" );
|
|||
#this one should fail
|
||||
my $sub2 = $frmB->addSubmission({
|
||||
title => 'why i like to be important',
|
||||
}, 'invalid submission fails' );
|
||||
});
|
||||
ok( not defined $sub2, "invalid submission failed" );
|
||||
|
||||
loginUserB;
|
||||
|
|
@ -235,14 +236,44 @@ cmp_deeply($sub1->get('comments')->[0],{
|
|||
}, "successfully added comment" );
|
||||
|
||||
ok($sub1->update({
|
||||
title => 'the new title'
|
||||
}),'update submission');
|
||||
|
||||
is( $sub1->get('title'),'the new title','successfully changed the title');
|
||||
|
||||
|
||||
ok($sub1->update({
|
||||
status => 'approved'
|
||||
}),'set status to approved');
|
||||
|
||||
ok($sub2->update({
|
||||
status => 'denied'
|
||||
}),'set status to denied');
|
||||
|
||||
# create the workflows/activities for processing
|
||||
my $approveSubmissions = WebGUI::Test::Activity->create( $session,
|
||||
"WebGUI::Workflow::Activity::ProcessEMSApprovals"
|
||||
);
|
||||
my $cleanupSubmissions = WebGUI::Test::Activity->create( $session,
|
||||
"WebGUI::Workflow::Activity::CleanupEMSSubmissions"
|
||||
);
|
||||
|
||||
is($approveSubmissions->run, 'complete', 'approval complete');
|
||||
is($approveSubmissions->run, 'done', 'approval done');
|
||||
|
||||
is( $sub1->get('status'),'created','submission has been created');
|
||||
|
||||
my $TODO = q{
|
||||
modify submission(s)
|
||||
change submission status
|
||||
run submission approval activity
|
||||
can we look for the EMSTicket asset for the created submission?
|
||||
-- perhaps it should be assigned to the ticket somehow?
|
||||
run addpoval on a submission that is missing data
|
||||
-- approval runs fine, but status should be failed
|
||||
update submissions to be more than a day old
|
||||
run submission cleanup activity
|
||||
-- cleanup only denied entries
|
||||
-- cleanup denied and created entries
|
||||
};
|
||||
|
||||
$versionTag->commit;
|
||||
|
||||
#done_testing();
|
||||
|
|
@ -250,6 +281,7 @@ $versionTag->commit;
|
|||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
# everything should be entered into the WG::Test cleanup lists...
|
||||
$approveSubmissions->delete;
|
||||
$cleanupSubmissions->delete;
|
||||
}
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
96
t/lib/WebGUI/Test/Activity.pm
Normal file
96
t/lib/WebGUI/Test/Activity.pm
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
package WebGUI::Test::Activity;
|
||||
|
||||
use WebGUI::Workflow;
|
||||
|
||||
=head Name
|
||||
|
||||
package WebGUI::Test::Activity;
|
||||
|
||||
=head Description
|
||||
|
||||
This package encapsulates the code required to run
|
||||
an activity.
|
||||
|
||||
=head Usage
|
||||
|
||||
use WebGUI::Test::Activity;
|
||||
|
||||
my $instance = WebGUI::Test::Activity->create( $session, 'WebGUI::Workflow::Activity::RemoveOldCarts', {
|
||||
cartTimeout => 3600,
|
||||
} );
|
||||
|
||||
is( $instance->run, 'complete', 'activity complete' );
|
||||
is( $instance->run, 'done', 'activity done' );
|
||||
$instance->rerun;
|
||||
is( $instance->run, 'complete', 'activity complete' );
|
||||
is( $instance->run, 'done', 'activity done' );
|
||||
$instance->delete;
|
||||
|
||||
=head create
|
||||
|
||||
=params
|
||||
|
||||
session -- the session variable
|
||||
|
||||
class -- the class for the activity to run
|
||||
|
||||
params -- params to set in the workflow
|
||||
|
||||
=cut
|
||||
|
||||
sub create {
|
||||
my $myClass = shift;
|
||||
my $session = shift;
|
||||
my $workflowClass = shift;
|
||||
my $activityParams;
|
||||
if( exists $_[0] and ref $_[0] eq 'HASH' ) {
|
||||
$activityParams = shift ;
|
||||
} else {
|
||||
$activityParams = { @_ };
|
||||
}
|
||||
my $workflow = WebGUI::Workflow->create($session,
|
||||
{
|
||||
enabled => 1,
|
||||
objectType => 'None',
|
||||
mode => 'realtime',
|
||||
},
|
||||
);
|
||||
my $activity = $workflow->addActivity($workflowClass);
|
||||
if( scalar( keys %$activityParams ) > 0 ) {
|
||||
$activity->set(%$activityParams);
|
||||
}
|
||||
|
||||
my $instance = WebGUI::Workflow::Instance->create($session,
|
||||
{
|
||||
workflowId => $workflow->getId,
|
||||
skipSpectreNotification => 1,
|
||||
}
|
||||
);
|
||||
return bless { instance => $instance,
|
||||
session => $session,
|
||||
workflow => $workflow }, __PACKAGE__;
|
||||
}
|
||||
|
||||
sub run {
|
||||
return $_[0]{instance}->run;
|
||||
}
|
||||
|
||||
sub rerun {
|
||||
my $self = shift;
|
||||
$self->{instance}->delete;
|
||||
$self->{instance} = WebGUI::Workflow::Instance->create($self->{session},
|
||||
{
|
||||
workflowId => $self->{workflow}->getId,
|
||||
skipSpectreNotification => 1,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
sub delete {
|
||||
my $self = shift;
|
||||
$self->{instance}->delete;
|
||||
$self->{workflow}->delete;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue