[Rt-commit] rt branch, 4.0/allow-group-to-change-name-cases, created. rt-4.0.10-108-g409a7b2
? sunnavy
sunnavy at bestpractical.com
Sun Mar 17 10:23:43 EDT 2013
The branch, 4.0/allow-group-to-change-name-cases has been created
at 409a7b20fcd9f7cc8cb4dc9bb719a549ae97beb6 (commit)
- Log -----------------------------------------------------------------
commit 409a7b20fcd9f7cc8cb4dc9bb719a549ae97beb6
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sun Mar 17 22:07:42 2013 +0800
allow group names to change their cases.
we shall mark the new name valid if the duplicated group we found(which was
loaded by name case-insensitively) is the same one that is going to change.
diff --git a/lib/RT/Group.pm b/lib/RT/Group.pm
index 0c6028c..d4d2802 100644
--- a/lib/RT/Group.pm
+++ b/lib/RT/Group.pm
@@ -529,8 +529,9 @@ sub _ValidateUserDefinedName {
my $dupcheck = RT::Group->new(RT->SystemUser);
$dupcheck->LoadUserDefinedGroup($value);
- return (0, $self->loc("Group name '[_1]' is already in use", $value))
- if $dupcheck->id;
+ if ( $dupcheck->id && ( !$self->id || $self->id != $dupcheck->id ) ) {
+ return ( 0, $self->loc( "Group name '[_1]' is already in use", $value ) );
+ }
return 1;
}
diff --git a/t/api/group.t b/t/api/group.t
index 3ce3da9..2c1ca73 100644
--- a/t/api/group.t
+++ b/t/api/group.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
use RT;
-use RT::Test nodata => 1, tests => 38;
+use RT::Test nodata => 1, tests => undef;
{
@@ -94,3 +94,18 @@ is($u->PrincipalObj->PrincipalType , 'Group' , "Principal 4 is a group");
}
+{
+ my $u = RT::Group->new(RT->SystemUser);
+ $u->LoadUserDefinedGroup('TestGroup');
+ ok( $u->id, 'loaded TestGroup' );
+ ok( $u->SetName('testgroup'), 'rename to lower cased version: testgroup' );
+ ok( $u->SetName('TestGroup'), 'rename back' );
+
+ my $u2 = RT::Group->new( RT->SystemUser );
+ my ( $id, $msg ) = $u2->CreateUserDefinedGroup( Name => 'TestGroup' );
+ ok( !$id, "can't create duplicated group: $msg" );
+ ( $id, $msg ) = $u2->CreateUserDefinedGroup( Name => 'testgroup' );
+ ok( !$id, "can't create duplicated group even case is different: $msg" );
+}
+
+done_testing;
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list