[Rt-commit] rt branch, 4.4/dryrun-customfield-on-update, created. rt-4.4.3-196-g5f2b130ba
Craig Kaiser
craig at bestpractical.com
Fri Jan 25 13:17:23 EST 2019
The branch, 4.4/dryrun-customfield-on-update has been created
at 5f2b130ba6753f6e96e962b2492a6b8026072382 (commit)
- Log -----------------------------------------------------------------
commit 69774c50df0870b9f2de6ed72f5ce3da07d7a943
Author: Craig Kaiser <craig at bestpractical.com>
Date: Fri Jan 25 11:09:00 2019 -0500
Add failing test for customfield with value on update page
When a customfield has a value on the update page it will result in
the dry run functionality to fail and a full commit to occur instead.
diff --git a/t/web/dryrun.t b/t/web/dryrun.t
new file mode 100644
index 000000000..a7a3119ee
--- /dev/null
+++ b/t/web/dryrun.t
@@ -0,0 +1,61 @@
+use strict;
+use warnings;
+
+use RT::Test tests => undef;
+
+my ($baseurl, $agent) = RT::Test->started_ok;
+
+my $url = $agent->rt_base_url;
+
+
+{
+ $agent->login('root' => 'password');
+ # the field isn't named, so we have to click link 0
+ is( $agent->status, 200, "Fetched the page ok");
+ $agent->content_contains("Logout", "Found a logout link");
+}
+my ($ok, $msg);
+my $ticket = RT::Ticket->new(RT->SystemUser);
+my ($tv,$ttv,$tm) = $ticket->Create(
+ Queue => 'General',
+ Subject => "An Interesting Title",
+);
+ok($tv, $tm);
+
+my $cf = RT::CustomField->new(RT->SystemUser);
+ok($cf, "Have a CustomField object");
+($ok, $msg) = $cf->Create(
+ Name => 'MyCF',
+ Queue => '0',
+ Description => 'A Testing custom field',
+ Type => 'SelectSingle'
+);
+ok($ok, 'Global custom field correctly created');
+my $cf_id = $cf->Id;
+
+($ok, $msg) = $ticket->Load($tv);
+ok($ok, 'created a scrip') or diag "error: $msg";
+
+$ticket->AddCustomFieldValue(Field => $cf->Id, Value => '1');
+my $scrip = RT::Scrip->new(RT->SystemUser);
+($ok, $msg) = $scrip->Create(
+ Queue => 'General',
+ ScripAction => 'User Defined',
+ ScripCondition => 'User Defined',
+ Template => 'blank',
+ CustomIsApplicableCode => "return 1;",
+ CustomPrepareCode => "1;",
+ CustomCommitCode => "warn 'Fail test for warning'",
+);
+ok($ok, 'created a scrip') or diag "error: $msg";
+
+$agent->get( $url."Ticket/Update.html?Action=Respond;id=$tv" );
+$agent->post_ok( $url."Helpers/PreviewScrips", {
+ id => $tv,
+ "Object-RT::Ticket-$tv-CustomField-$cf_id-Value" => 'Test Value',
+ UpdateType => 'response',
+ TxnRecipients => 'root at localhost',
+}, Content_Type => 'form-data' );
+is( $agent->status, 200, "Fetched the page ok");
+
+done_testing();
commit 5f2b130ba6753f6e96e962b2492a6b8026072382
Author: Craig Kaiser <craig at bestpractical.com>
Date: Fri Jan 25 11:10:06 2019 -0500
Pass Object key to 'ProcessObjectCustomFieldUpdates' not TicketObj
If the Object key is not passed then the 'DryRun' arg is lost and a
commit will be run instead of a dry run.
diff --git a/share/html/Helpers/PreviewScrips b/share/html/Helpers/PreviewScrips
index 14fa77344..6303fd7c5 100644
--- a/share/html/Helpers/PreviewScrips
+++ b/share/html/Helpers/PreviewScrips
@@ -68,7 +68,7 @@ my @dryrun = $TicketObj->DryRun(
ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $TicketObj );
ProcessTicketLinks( ARGSRef => \%ARGS, TicketObj => $TicketObj );
ProcessTicketDates( ARGSRef => \%ARGS, TicketObj => $TicketObj );
- ProcessObjectCustomFieldUpdates(ARGSRef => \%ARGS, TicketObj => $TicketObj );
+ ProcessObjectCustomFieldUpdates(ARGSRef => \%ARGS, Object => $TicketObj );
ProcessTicketReminders( ARGSRef => \%ARGS, TicketObj => $TicketObj );
}
);
diff --git a/share/html/Ticket/Display.html b/share/html/Ticket/Display.html
index 87a663ebf..2681a3831 100644
--- a/share/html/Ticket/Display.html
+++ b/share/html/Ticket/Display.html
@@ -191,7 +191,7 @@ if ($ARGS{'id'} eq 'new') {
push @Actions, ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $TicketObj );
push @Actions, ProcessTicketLinks( ARGSRef => \%ARGS, TicketObj => $TicketObj );
push @Actions, ProcessTicketDates( ARGSRef => \%ARGS, TicketObj => $TicketObj );
- push @Actions, ProcessObjectCustomFieldUpdates(ARGSRef => \%ARGS, TicketObj => $TicketObj );
+ push @Actions, ProcessObjectCustomFieldUpdates(ARGSRef => \%ARGS, Object => $TicketObj );
push @Actions, ProcessTicketReminders( ARGSRef => \%ARGS, TicketObj => $TicketObj );
});
if ( !$SkipProcessing ) {
-----------------------------------------------------------------------
More information about the rt-commit
mailing list