[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.8-100-gfbbea56

? sunnavy sunnavy at bestpractical.com
Mon Jun 28 03:58:31 EDT 2010


The branch, 3.8-trunk has been updated
       via  fbbea56f36f87b8907036f1349eee5d99ed9056a (commit)
      from  c8f0e722c5cb81e72e2e3abc89ddfc0c396bc0f7 (commit)

Summary of changes:
 share/html/Admin/CustomFields/Modify.html |    8 ++++++--
 t/web/cf_select_one.t                     |   10 +++++++---
 2 files changed, 13 insertions(+), 5 deletions(-)

- Log -----------------------------------------------------------------
commit fbbea56f36f87b8907036f1349eee5d99ed9056a
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Jun 28 15:26:42 2010 +0800

    not allow heading and trailing spaces for CustomFieldValues, as ObjectCustomFieldValues doesn't allow that anyway

diff --git a/share/html/Admin/CustomFields/Modify.html b/share/html/Admin/CustomFields/Modify.html
index f75607a..5662226 100644
--- a/share/html/Admin/CustomFields/Modify.html
+++ b/share/html/Admin/CustomFields/Modify.html
@@ -199,6 +199,8 @@ if ( $ARGS{'Update'} && $id ne 'new' ) {
         foreach my $attr qw(Name Description SortOrder Category) {
             my $param = join("-", $paramtag, $value->Id, $attr);
             next unless exists $ARGS{$param};
+            $ARGS{$param} =~ s/^\s+//;
+            $ARGS{$param} =~ s/\s+$//;
             next if ($value->$attr()||'') eq ($ARGS{$param}||'');
 
             my $mutator = "Set$attr";
@@ -210,8 +212,10 @@ if ( $ARGS{'Update'} && $id ne 'new' ) {
     # Add any new values
     if ( defined $ARGS{ $paramtag ."-new-Name" } && length $ARGS{ $paramtag ."-new-Name" } ) {
         my ($id, $msg) = $CustomFieldObj->AddValue(
-            map { $_ => $ARGS{ $paramtag ."-new-$_" } }
-                qw( Name Description SortOrder Category )
+            map { 
+                $ARGS{$paramtag."-new-$_"} =~ s/^\s+//;
+                $ARGS{$paramtag."-new-$_"} =~ s/\s+$//;
+                $_ => $ARGS{ $paramtag ."-new-$_" } } qw/ Name Description SortOrder Category/
         );
         push (@results, $msg);
     }
diff --git a/t/web/cf_select_one.t b/t/web/cf_select_one.t
index 39a8080..26c1fcf 100644
--- a/t/web/cf_select_one.t
+++ b/t/web/cf_select_one.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 41;
+use RT::Test tests => 46;
 
 my ($baseurl, $m) = RT::Test->started_ok;
 ok $m->login, 'logged in as root';
@@ -31,9 +31,9 @@ diag "Create a CF" if $ENV{'TEST_VERBOSE'};
     ok $cfid, "found id of the CF in the form, it's #$cfid";
 }
 
-diag "add 'qwe', 'ASD' and '0' as values to the CF" if $ENV{'TEST_VERBOSE'};
+diag "add 'qwe', 'ASD', '0' and ' foo ' as values to the CF" if $ENV{'TEST_VERBOSE'};
 {
-    foreach my $value(qw(qwe ASD 0)) {
+    foreach my $value(qw(qwe ASD 0), 'foo ') {
         $m->submit_form(
             form_name => "ModifyCustomField",
             fields => {
@@ -42,6 +42,10 @@ diag "add 'qwe', 'ASD' and '0' as values to the CF" if $ENV{'TEST_VERBOSE'};
             button => 'Update',
         );
         $m->content_like( qr/Object created/, 'added a value to the CF' ); # or diag $m->content;
+        my $v = $value;
+        $v =~ s/^\s+$//;
+        $v =~ s/\s+$//;
+        $m->content_like( qr/value="$v"/, 'the added value is right' );
     }
 }
 

-----------------------------------------------------------------------


More information about the Rt-commit mailing list