[Rt-commit] rt branch, set-undefined-email-fix, updated. rt-4.0.0-170-g6314535

? sunnavy sunnavy at bestpractical.com
Mon May 2 12:23:05 EDT 2011


The branch, set-undefined-email-fix has been updated
       via  6314535dbd32b5fcae3f4c90ee6a995589605e0a (commit)
      from  3aaa892cbe08aa02abc2daa74bee13c3e64f117e (commit)

Summary of changes:
 lib/RT/User.pm |    3 ++-
 t/api/user.t   |   10 +++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit 6314535dbd32b5fcae3f4c90ee6a995589605e0a
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue May 3 00:04:42 2011 +0800

    RT::User->SetEmailAddress(undef) means to empty it

diff --git a/lib/RT/User.pm b/lib/RT/User.pm
index b8bf0af..87e3130 100644
--- a/lib/RT/User.pm
+++ b/lib/RT/User.pm
@@ -579,8 +579,9 @@ so that a better email address can be returned
 =cut
 
 sub SetEmailAddress {
-    my $self = shift;
+    my $self  = shift;
     my $Value = shift;
+    $Value = '' unless defined $Value;
 
     my ($val, $message) = $self->ValidateEmailAddress( $Value );
     if ( $val ) {
diff --git a/t/api/user.t b/t/api/user.t
index f057771..e6b891f 100644
--- a/t/api/user.t
+++ b/t/api/user.t
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 use RT;
-use RT::Test tests => 108;
+use RT::Test tests => 111;
 
 
 {
@@ -59,6 +59,14 @@ ok ($id, $msg);
 ok ($id, $msg);
 is_empty ($u7->EmailAddress);
 
+# back to something, so we can set undef next successfully
+($id,$msg) = $u7->SetEmailAddress('foo at bar'.$$);
+ok ($id, $msg);
+
+($id,$msg) = $u7->SetEmailAddress(undef);
+ok ($id, $msg);
+is_empty ($u7->EmailAddress);
+
 RT->Config->Set('ValidateUserEmailAddresses' => 1);
 # Make sur we can't create a user with multiple email adresses separated by comma
 my $u8 = RT::User->new(RT->SystemUser);

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


More information about the Rt-commit mailing list