[Rt-commit] rt branch, 4.4/update-starts-on-sla-change, created. rt-4.4.2-104-ge9a93d456
? sunnavy
sunnavy at bestpractical.com
Thu Mar 29 13:07:00 EDT 2018
The branch, 4.4/update-starts-on-sla-change has been created
at e9a93d456b599ebdd8a874631d1b382cff2855a2 (commit)
- Log -----------------------------------------------------------------
commit d0f17c654557996ccc35f81529468820fa0754fa
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Mar 30 00:14:18 2018 +0800
Update Starts on SLA changes
Previously SLA_RequireStartsSet condition returned false if Starts is
already set, which prevented Starts from being updated automatically by
SLA changes.
This commit fixes it so it could set Starts whenever SLA is changed.
Fixes: I#32028
diff --git a/lib/RT/Condition/SLA_RequireStartsSet.pm b/lib/RT/Condition/SLA_RequireStartsSet.pm
index 260455a3d..1e1108f7b 100644
--- a/lib/RT/Condition/SLA_RequireStartsSet.pm
+++ b/lib/RT/Condition/SLA_RequireStartsSet.pm
@@ -65,10 +65,14 @@ Applies if Starts date is not set for the ticket.
sub IsApplicable {
my $self = shift;
- return 0 if $self->TicketObj->StartsObj->Unix > 0;
return 0 if $self->TicketObj->QueueObj->SLADisabled;
return 0 unless $self->TicketObj->SLA;
- return 1;
+
+ my $type = $self->TransactionObj->Type;
+ return 1 if $type eq 'Create';
+ return 1 if $type eq 'Set' && $self->TransactionObj->Field eq 'SLA';
+
+ return 0;
}
1;
commit e9a93d456b599ebdd8a874631d1b382cff2855a2
Author: Dave Goehrig <dave at bestpractical.com>
Date: Fri Mar 30 00:05:02 2018 +0800
Test Starts on SLA changes
diff --git a/t/sla/starts.t b/t/sla/starts.t
index b180ff038..798bb977b 100644
--- a/t/sla/starts.t
+++ b/t/sla/starts.t
@@ -78,4 +78,39 @@ diag 'check Starts date with StartImmediately enabled' if $ENV{'TEST_VERBOSE'};
is $starts, $ticket->CreatedObj->Unix, 'Starts is correct';
}
+
+diag 'check changing start time' if $ENV{'TEST_VERBOSE'};
+{
+ RT->Config->Set(ServiceAgreements => (
+ Default => 'standard',
+ Levels => {
+ 'standard' => {
+ Starts => 60,
+ Response => 2 * 60,
+ Resolve => 7 * 60 * 24,
+ },
+ 'nonstandard' => {
+ Starts => 2 * 60,
+ Response => 3 * 60,
+ Resolve => 4 * 60
+ }
+ },
+ ));
+
+ my $ticket = RT::Ticket->new($RT::SystemUser);
+ my ($id) = $ticket->Create( Queue => 'General', Subject => 'test sla start time change');
+ ok $id, "Created ticket $id";
+
+ my $starts = $ticket->StartsObj->Unix;
+ ok $starts > 0, 'Starts date is set';
+
+ $ticket->SetSLA('nonstandard');
+ my $new_starts = $ticket->StartsObj->Unix;
+ is $new_starts - $starts, 3600, 'Starts time changed on SLA update';
+
+ $ticket->SetSLA('standard');
+ my $reset_starts = $ticket->StartsObj->Unix;
+ is $reset_starts, $starts, 'Start date reset';
+}
+
done_testing;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list