[Rt-commit] rt branch, 5.0/rest2-test-custom-field-name-with-spaces, created. rt-5.0.0-69-ga8bf31fa77
? sunnavy
sunnavy at bestpractical.com
Tue Nov 3 11:12:17 EST 2020
The branch, 5.0/rest2-test-custom-field-name-with-spaces has been created
at a8bf31fa77dae42d39dca87727fe3939fe26445e (commit)
- Log -----------------------------------------------------------------
commit a8bf31fa77dae42d39dca87727fe3939fe26445e
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Nov 3 15:21:13 2020 +0800
Test ticket custom field updates with names containing spaces in REST2
diff --git a/t/rest2/ticket-customfields.t b/t/rest2/ticket-customfields.t
index 624a58dc1d..88722942b9 100644
--- a/t/rest2/ticket-customfields.t
+++ b/t/rest2/ticket-customfields.t
@@ -1174,5 +1174,34 @@ my $json = JSON->new->utf8;
}
}
+{
+ my $space_cf = RT::CustomField->new( RT->SystemUser );
+ my ( $ok, $msg ) = $space_cf->Create( Name => 'Single Text', Type => 'FreeformSingle', Queue => $queue->Id );
+ ok( $ok, $msg );
+
+ my $payload = {
+ Queue => 'General',
+ Subject => 'Ticket creation with custom field names containing spaces',
+ Content => 'Testing ticket creation using REST API.',
+ CustomFields => { 'Single Text' => 'Hello world!', },
+ };
+
+ my $res = $mech->post_json( "$rest_base_path/ticket", $payload, 'Authorization' => $auth, );
+ is( $res->code, 201 );
+ ok( $ticket_url = $res->header('location') );
+ ok( ($ticket_id) = $ticket_url =~ qr[/ticket/(\d+)] );
+
+ my $ticket = RT::Ticket->new($user);
+ $ticket->Load($ticket_id);
+ is( $ticket->FirstCustomFieldValue($space_cf), 'Hello world!', 'custom field value is set' );
+
+ $payload = { CustomFields => { 'Single Text' => 'Howdy world!', }, };
+
+ $res = $mech->put_json( $ticket_url, $payload, 'Authorization' => $auth, );
+ is( $res->code, 200 );
+ is_deeply( $mech->json_response, ["Single Text Hello world! changed to Howdy world!"] );
+ is( $ticket->FirstCustomFieldValue($space_cf), 'Howdy world!', 'custom field value is updated' );
+}
+
done_testing;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list