[Rt-commit] r8215 - in rt/branches/3.6-RELEASE: . bin html/REST/1.0 lib/t/regression

jesse at bestpractical.com jesse at bestpractical.com
Wed Jul 18 19:12:52 EDT 2007


Author: jesse
Date: Wed Jul 18 19:12:52 2007
New Revision: 8215

Modified:
   rt/branches/3.6-RELEASE/   (props changed)
   rt/branches/3.6-RELEASE/bin/rt.in
   rt/branches/3.6-RELEASE/html/REST/1.0/dhandler
   rt/branches/3.6-RELEASE/lib/RT/Interface/REST.pm
   rt/branches/3.6-RELEASE/lib/t/regression/26command_line.t

Log:
 r60938 at pinglin:  jesse | 2007-07-18 19:12:15 -0400
 * Fixed RT REST API and commandline client to support custom fields with spaces in their names
 


Modified: rt/branches/3.6-RELEASE/bin/rt.in
==============================================================================
--- rt/branches/3.6-RELEASE/bin/rt.in	(original)
+++ rt/branches/3.6-RELEASE/bin/rt.in	Wed Jul 18 19:12:52 2007
@@ -92,7 +92,7 @@
 # (XXX: Ask Autrijus how i18n changes these definitions.)
 
 my $name   = '[\w.-]+';
-my $field  = '[a-zA-Z][a-zA-Z0-9_-]*';
+my $field  = '(?:[a-zA-Z](?:[a-zA-Z0-9_-]|\s+)*)';
 my $label  = '[a-zA-Z0-9 at _.+-]+';
 my $labels = "(?:$label,)*$label";
 my $idlist = '(?:(?:\d+-)?\d+,)*(?:\d+-)?\d+';

Modified: rt/branches/3.6-RELEASE/html/REST/1.0/dhandler
==============================================================================
--- rt/branches/3.6-RELEASE/html/REST/1.0/dhandler	(original)
+++ rt/branches/3.6-RELEASE/html/REST/1.0/dhandler	Wed Jul 18 19:12:52 2007
@@ -63,7 +63,7 @@
 my $name   = qr{[\w.-]+};
 my $list   = '(?:(?:\d+-)?\d+,)*(?:\d+-)?\d+';
 my $label  = '[a-zA-Z0-9 at _.+-]+';
-my $field  = '[a-zA-Z][a-zA-Z0-9_-]*';
+my $field  = '[a-zA-Z](?:[a-zA-Z0-9_-]|\s+)*';
 my $labels = "(?:$label,)*$label";
 
 # We must handle requests such as the following:

Modified: rt/branches/3.6-RELEASE/lib/RT/Interface/REST.pm
==============================================================================
--- rt/branches/3.6-RELEASE/lib/RT/Interface/REST.pm	(original)
+++ rt/branches/3.6-RELEASE/lib/RT/Interface/REST.pm	Wed Jul 18 19:12:52 2007
@@ -62,7 +62,7 @@
     @EXPORT = qw(expand_list form_parse form_compose vpush vsplit);
 }
 
-my $field = '(?i:[a-z][a-z0-9_-]*|C(?:ustom)?F(?:ield)?-[a-z0-9_ -]+)';
+my $field = '(?i:[a-z][a-z0-9_-]*|C(?:ustom)?F(?:ield)?-(?:[a-z0-9_ -]|\s)+)';
 
 # WARN: this code is duplicated in bin/rt.in,
 # change both functions at once
@@ -122,7 +122,7 @@
                 }
                 $c .= "\n";
             }
-            elsif ($state <= 1 && $line =~ /^($field):(?:\s+(.*))?$/) {
+            elsif ($state <= 1 && $line =~ /^($field):(?:\s+(.*))?$/i) {
                 # Read a field: value specification.
                 my $f  = $1;
                 my @v  = ($2 || ());

Modified: rt/branches/3.6-RELEASE/lib/t/regression/26command_line.t
==============================================================================
--- rt/branches/3.6-RELEASE/lib/t/regression/26command_line.t	(original)
+++ rt/branches/3.6-RELEASE/lib/t/regression/26command_line.t	Wed Jul 18 19:12:52 2007
@@ -3,7 +3,7 @@
 use strict;
 use Test::Expect;
 #use Test::More qw/no_plan/;
-use Test::More tests => 202;
+use Test::More tests => 216;
 
 use RT;
 RT::LoadConfig();
@@ -90,6 +90,18 @@
 
 # }}}
 
+
+# Set up a custom field for editing tests
+my $cf = RT::CustomField->new($RT::SystemUser);
+my ($val,$msg) = $cf->Create(Name => 'MyCF'.$$, Type => 'FreeformSingle', Queue => $queue_id);
+ok($val,$msg);
+
+my $othercf = RT::CustomField->new($RT::SystemUser);
+($val,$msg) = $othercf->Create(Name => 'My CF'.$$, Type => 'FreeformSingle', Queue => $queue_id);
+ok($val,$msg);
+
+
+
 # add a comment to ticket
     expect_send("comment -m 'comment-$$' $ticket_id", "Adding a comment...");
     expect_like(qr/Message recorded/, "Added the comment");
@@ -135,6 +147,22 @@
 expect_like(qr/queue does not exist/i, 'Errored out');
 expect_send("show ticket/$ticket_id -f queue", 'Verifying lack of change...');
 expect_like(qr/Queue: EditedQueue$$/, 'Verified lack of change');
+
+# Test reading and setting custom fields without spaces
+expect_send("show ticket/$ticket_id -f CF-myCF$$", 'Checking initial value');
+expect_like(qr/CF-myCF$$:/i, 'Verified initial empty value');
+expect_send("edit ticket/$ticket_id set 'CF-myCF$$=VALUE' ", 'Changing CF...');
+expect_like(qr/Ticket $ticket_id updated/, 'Changed cf');
+expect_send("show ticket/$ticket_id -f CF-myCF$$", 'Checking new value');
+expect_like(qr/CF-myCF$$: VALUE/i, 'Verified change');
+# Test reading and setting custom fields with spaces
+expect_send("show ticket/$ticket_id -f 'CF-my CF$$'", 'Checking initial value');
+expect_like(qr/my CF$$:/i, 'Verified change');
+expect_send("edit ticket/$ticket_id set 'CF-my CF$$=VALUE' ", 'Changing CF...');
+expect_like(qr/Ticket $ticket_id updated/, 'Changed cf');
+expect_send("show ticket/$ticket_id -f 'CF-my CF$$'", 'Checking new value');
+expect_like(qr/my CF$$: VALUE/i, 'Verified change');
+
 # ...
 # change a ticket's ...[other properties]...
 # ...


More information about the Rt-commit mailing list