Skip to content

Commit

Permalink
Allow 0 as a valid object CF value
Browse files Browse the repository at this point in the history
  • Loading branch information
tsibley committed Jun 9, 2012
1 parent 2ac2700 commit 87a75f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion lib/RT/Extension/LDAPImport.pm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -876,7 +876,13 @@ sub update_object_custom_field_values {
map { scalar $args{ldap_entry}->get_value($_) } map { scalar $args{ldap_entry}->get_value($_) }
@attributes; @attributes;


if (($obj->FirstCustomFieldValue($cf_name) || '') eq ($value || '')) { my $current = $obj->FirstCustomFieldValue($cf_name);

if (not defined $current and not defined $value) {
$self->_debug($obj->Name . ": Skipping '$cf_name'. No value in RT or LDAP.");
next;
}
elsif (defined $current and defined $value and $current eq $value) {
$self->_debug($obj->Name . ": Value '$value' is already set for '$cf_name'"); $self->_debug($obj->Name . ": Value '$value' is already set for '$cf_name'");
next; next;
} }
Expand Down
4 changes: 2 additions & 2 deletions t/user-import-cfs.t
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ok( my $server = Net::LDAP::Server::Test->new( $ldap_port, auto_schema => 1 ),
my $ldap = Net::LDAP->new("localhost:$ldap_port"); my $ldap = Net::LDAP->new("localhost:$ldap_port");
$ldap->bind(); $ldap->bind();
my @ldap_entries; my @ldap_entries;
for ( 1 .. 13 ) { for ( 0 .. 12 ) {
my $username = "testuser$_"; my $username = "testuser$_";
my $dn = "uid=$username,ou=foo,dc=bestpractical,dc=com"; my $dn = "uid=$username,ou=foo,dc=bestpractical,dc=com";
my $entry = { my $entry = {
Expand Down Expand Up @@ -78,7 +78,7 @@ for my $entry (@ldap_entries) {
Name => $entry->{uid} ); Name => $entry->{uid} );
ok($user->Id, "Found $entry->{cn} as ".$user->Id); ok($user->Id, "Found $entry->{cn} as ".$user->Id);
ok(!$user->Privileged, "User created as Unprivileged"); ok(!$user->Privileged, "User created as Unprivileged");
is($user->FirstCustomFieldValue('Employee Number'), $entry->{employeeId}, "cf is good"); is($user->FirstCustomFieldValue('Employee Number'), $entry->{employeeId}, "cf is good: $entry->{employeeId}");
} }


# import again, check that it was cleared # import again, check that it was cleared
Expand Down

0 comments on commit 87a75f1

Please sign in to comment.