X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Ft%2Fapi%2Fscrip.t;h=9d97e7344a0586685f81b74d5f3084238e9cb70a;hb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924;hp=8e8f96213df8e46d015a0a4bfa8cfa458e10827e;hpb=63a268637b2d51a8766412617724b9436439deb6;p=freeside.git diff --git a/rt/t/api/scrip.t b/rt/t/api/scrip.t index 8e8f96213..9d97e7344 100644 --- a/rt/t/api/scrip.t +++ b/rt/t/api/scrip.t @@ -2,7 +2,7 @@ use strict; use warnings; use RT; -use RT::Test tests => 7; +use RT::Test tests => 25; { @@ -46,4 +46,76 @@ isnt ($ticket2->Priority , '87', "Ticket priority is set right"); } + +{ + my $scrip = RT::Scrip->new($RT::SystemUser); + my ( $val, $msg ) = $scrip->Create( + ScripCondition => 'On Comment', + ScripAction => 'Notify Owner', + ); + ok( !$val, "missing template: $msg" ); + ( $val, $msg ) = $scrip->Create( + ScripCondition => 'On Comment', + ScripAction => 'Notify Owner', + Template => 'not exists', + ); + ok( !$val, "invalid template: $msg" ); + + ( $val, $msg ) = $scrip->Create( + ScripAction => 'Notify Owner', + Template => 'Blank', + ); + ok( !$val, "missing condition: $msg" ); + ( $val, $msg ) = $scrip->Create( + ScripCondition => 'not exists', + ScripAction => 'Notify Owner', + Template => 'Blank', + ); + ok( !$val, "invalid condition: $msg" ); + + ( $val, $msg ) = $scrip->Create( + ScripCondition => 'On Comment', + Template => 'Blank', + ); + ok( !$val, "missing action: $msg" ); + ( $val, $msg ) = $scrip->Create( + ScripCondition => 'On Comment', + ScripAction => 'not exists', + Template => 'Blank', + ); + ok( !$val, "invalid action: $msg" ); + + ( $val, $msg ) = $scrip->Create( + ScripAction => 'Notify Owner', + ScripCondition => 'On Comment', + Template => 'Blank', + ); + ok( $val, "created scrip: $msg" ); + $scrip->Load($val); + ok( $scrip->id, 'loaded scrip ' . $scrip->id ); + + ( $val, $msg ) = $scrip->SetScripCondition(); + ok( !$val, "missing condition: $msg" ); + ( $val, $msg ) = $scrip->SetScripCondition('not exists'); + ok( !$val, "invalid condition: $msg" ); + ( $val, $msg ) = $scrip->SetScripCondition('On Correspond'); + ok( $val, "updated condition to 'On Correspond': $msg" ); + + ( $val, $msg ) = $scrip->SetScripAction(); + ok( !$val, "missing action: $msg" ); + ( $val, $msg ) = $scrip->SetScripAction('not exists'); + ok( !$val, "invalid action: $msg" ); + ( $val, $msg ) = $scrip->SetScripAction('Notify AdminCcs'); + ok( $val, "updated action to 'Notify AdminCcs': $msg" ); + + ( $val, $msg ) = $scrip->SetTemplate(); + ok( !$val, "missing template $msg" ); + ( $val, $msg ) = $scrip->SetTemplate('not exists'); + ok( !$val, "invalid template $msg" ); + ( $val, $msg ) = $scrip->SetTemplate('Forward'); + ok( $val, "updated template to 'Forward': $msg" ); + + ok( $scrip->Delete, 'delete the scrip' ); +} + 1;