diff --git a/lib/WebGUI/Asset/EMSSubmission.pm b/lib/WebGUI/Asset/EMSSubmission.pm index a8493866c..c9ad97016 100644 --- a/lib/WebGUI/Asset/EMSSubmission.pm +++ b/lib/WebGUI/Asset/EMSSubmission.pm @@ -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', diff --git a/lib/WebGUI/Asset/EMSSubmissionForm.pm b/lib/WebGUI/Asset/EMSSubmissionForm.pm index c71abaf51..dd2de5d7f 100644 --- a/lib/WebGUI/Asset/EMSSubmissionForm.pm +++ b/lib/WebGUI/Asset/EMSSubmissionForm.pm @@ -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, diff --git a/lib/WebGUI/Workflow/Activity/CleanupEMSSubmissions.pm b/lib/WebGUI/Workflow/Activity/CleanupEMSSubmissions.pm index 1d7b08202..4d72f04d1 100644 --- a/lib/WebGUI/Workflow/Activity/CleanupEMSSubmissions.pm +++ b/lib/WebGUI/Workflow/Activity/CleanupEMSSubmissions.pm @@ -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) { diff --git a/lib/WebGUI/Workflow/Activity/ProcessEMSApprovals.pm b/lib/WebGUI/Workflow/Activity/ProcessEMSApprovals.pm index 9682609d6..092ee4f11 100644 --- a/lib/WebGUI/Workflow/Activity/ProcessEMSApprovals.pm +++ b/lib/WebGUI/Workflow/Activity/ProcessEMSApprovals.pm @@ -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) { diff --git a/lib/WebGUI/i18n/English/Asset_EMSSubmissionForm.pm b/lib/WebGUI/i18n/English/Asset_EMSSubmissionForm.pm index 9c664dde5..4b5c3a803 100644 --- a/lib/WebGUI/i18n/English/Asset_EMSSubmissionForm.pm +++ b/lib/WebGUI/i18n/English/Asset_EMSSubmissionForm.pm @@ -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|, diff --git a/t/Asset/EMSSubmissionForm.t b/t/Asset/EMSSubmissionForm.t index c452f9a6a..34b800c8a 100644 --- a/t/Asset/EMSSubmissionForm.t +++ b/t/Asset/EMSSubmissionForm.t @@ -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 diff --git a/t/lib/WebGUI/Test/Activity.pm b/t/lib/WebGUI/Test/Activity.pm new file mode 100644 index 000000000..51294e5b7 --- /dev/null +++ b/t/lib/WebGUI/Test/Activity.pm @@ -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; +