Commit c8ec075e authored by Ruslan Zakirov's avatar Ruslan Zakirov
Browse files

make sure you can not delete template in use

parent 7c99e149
......@@ -311,6 +311,10 @@ sub Delete {
return ( 0, $self->loc('Permission Denied') );
}
if ( $self->UsedBy->Count ) {
return ( 0, $self->loc('Template is in use') );
}
return ( $self->SUPER::Delete(@_) );
}
......
......@@ -2,7 +2,7 @@
use warnings;
use strict;
use RT::Test tests => 12;
use RT::Test tests => 29;
use_ok('RT::Template');
......@@ -107,6 +107,27 @@ note "changing queue of template is not implemented";
ok(!$val,$msg);
}
note "make sure template can not be deleted if it has scrips";
{
clean_templates( Queue => $queue->id );
my $template = RT::Template->new( RT->SystemUser );
my ($val,$msg) = $template->Create( Queue => $queue->id, Name => 'Test' );
ok($val,$msg);
my $scrip = RT::Scrip->new( RT->SystemUser );
($val,$msg) = $scrip->Create(
Queue => $queue->id,
ScripCondition => "On Create",
ScripAction => 'Autoreply To Requestors',
Template => $template->Name,
);
ok($val, $msg);
($val, $msg) = $template->Delete;
ok(!$val,$msg);
}
{
my $t = RT::Template->new(RT->SystemUser);
$t->Create(Name => "Foo", Queue => $queue->id);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment