[rt-commit] [svn] r611 - rt/branches/rt-3.3/lib/RT
autrijus at fsck.com
autrijus at fsck.com
Sat Mar 20 10:40:59 EST 2004
Author: autrijus
Date: Sat Mar 20 10:40:58 2004
New Revision: 611
Modified:
rt/branches/rt-3.3/lib/RT/CurrentUser.pm
rt/branches/rt-3.3/lib/RT/CustomField_Overlay.pm
rt/branches/rt-3.3/lib/RT/Ticket_Overlay.pm
rt/branches/rt-3.3/lib/RT/User_Overlay.pm
Log:
* merge Jesse's $RT::SystemUser->LanguageHandle fix; corrected a
bug caused by it in setup database stage where there's no SystemUser.
* fixed two tests in RT::CustomField that incorrectly expected old-style
->Type return values; they now test ->Type and ->MaxValues separately.
* change some ok() tests into is() and like() tests.
Modified: rt/branches/rt-3.3/lib/RT/CurrentUser.pm
==============================================================================
--- rt/branches/rt-3.3/lib/RT/CurrentUser.pm (original)
+++ rt/branches/rt-3.3/lib/RT/CurrentUser.pm Sat Mar 20 10:40:58 2004
@@ -314,32 +314,39 @@
=begin testing
ok (my $cu = RT::CurrentUser->new('root'));
-ok (my $lh = $cu->LanguageHandle);
+ok (my $lh = $cu->LanguageHandle('en-us'));
ok ($lh != undef);
ok ($lh->isa('Locale::Maketext'));
-ok ($cu->loc('TEST_STRING') eq "Concrete Mixer", "Localized TEST_STRING into English");
+is ($cu->loc('TEST_STRING'), "Concrete Mixer", "Localized TEST_STRING into English");
ok ($lh = $cu->LanguageHandle('fr'));
-ok ($cu->loc('Before') eq "Avant", "Localized TEST_STRING into Frenc");
+is ($cu->loc('Before'), "Avant", "Localized TEST_STRING into Frenc");
=end testing
=cut
sub LanguageHandle {
- my $self = shift;
- if ((!defined $self->{'LangHandle'}) ||
- (!UNIVERSAL::can($self->{'LangHandle'}, 'maketext')) ||
- (@_)) {
- if ( $self->Lang) {
- push @_, $self->Lang;
- }
- $self->{'LangHandle'} = RT::I18N->get_handle(@_);
- }
- # Fall back to english.
- unless ($self->{'LangHandle'}) {
- die "We couldn't get a dictionary. Nye mogu naidti slovar. No puedo encontrar dictionario.";
- }
- return ($self->{'LangHandle'});
+ my $self = shift;
+ if ( ( !defined $self->{'LangHandle'} )
+ || ( !UNIVERSAL::can( $self->{'LangHandle'}, 'maketext' ) )
+ || (@_) ) {
+
+ if ( $RT::SystemUser and $self->id == $RT::SystemUser->id() ) {
+ @_ = qw(en-US);
+ }
+
+ elsif ( $self->Lang ) {
+ push @_, $self->Lang;
+ }
+ $self->{'LangHandle'} = RT::I18N->get_handle(@_);
+ }
+
+ # Fall back to english.
+ unless ( $self->{'LangHandle'} ) {
+ die "We couldn't get a dictionary. Nye mogu naidti slovar. No
+puedo encontrar dictionario.";
+ }
+ return ( $self->{'LangHandle'} );
}
sub loc {
Modified: rt/branches/rt-3.3/lib/RT/CustomField_Overlay.pm
==============================================================================
--- rt/branches/rt-3.3/lib/RT/CustomField_Overlay.pm (original)
+++ rt/branches/rt-3.3/lib/RT/CustomField_Overlay.pm Sat Mar 20 10:40:58 2004
@@ -201,10 +201,12 @@
Type=> 'SelectSingle'), 'Created a global CustomField');
ok($id != 0, 'Global custom field correctly created');
ok ($cf->SingleValue);
-ok($cf->Type eq 'SelectSingle');
+is($cf->Type, 'Select');
+is($cf->MaxValues, 1);
ok($cf->SetType('SelectMultiple'));
-ok($cf->Type eq 'SelectMultiple');
+is($cf->Type, 'Select');
+is($cf->MaxValues, 0);
ok(!$cf->SingleValue );
ok(my ($bogus_val, $bogus_msg) = $cf->SetType('BogusType') , "Trying to set a custom field's type to a bogus type");
ok($bogus_val == 0, "Unable to set a custom field's type to a bogus type");
@@ -535,12 +537,27 @@
my $self = shift;
my $type = shift;
+ if ($type =~ s/(?:Single|Multiple)$//) {
+ warn "Prefix 'Single' and 'Multiple' to Type deprecated, use MaxValues instead";
+ }
+
if( $TYPES{$type}) {
return(1);
}
else {
return undef;
}
+}
+
+
+sub SetType {
+ my $self = shift;
+ my $type = shift;
+ if ($type =~ s/(?:(Single)|Multiple)$//) {
+ warn "'Single' and 'Multiple' on SetType deprecated, use SetMaxValues instead";
+ $self->SetMaxValues($1 ? 1 : 0);
+ }
+ $self->SUPER::SetType($type);
}
# {{{ SingleValue
Modified: rt/branches/rt-3.3/lib/RT/Ticket_Overlay.pm
==============================================================================
--- rt/branches/rt-3.3/lib/RT/Ticket_Overlay.pm (original)
+++ rt/branches/rt-3.3/lib/RT/Ticket_Overlay.pm Sat Mar 20 10:40:58 2004
@@ -85,8 +85,8 @@
ok(my $t2 = RT::Ticket->new($RT::SystemUser));
ok($t2->Load($id));
-ok($t2->Subject eq 'Testing');
-ok($t2->QueueObj->Id eq $testqueue->id);
+is($t2->Subject, 'Testing');
+is($t2->QueueObj->Id, $testqueue->id);
ok($t2->OwnerObj->Id == $u->Id);
my $t3 = RT::Ticket->new($RT::SystemUser);
@@ -3122,9 +3122,9 @@
my $t = RT::Ticket->new($RT::SystemUser);
$t->Load(1);
$t->SetOwner('root');
-ok ($t->OwnerObj->Name eq 'root' , "Root owns the ticket");
+is ($t->OwnerObj->Name, 'root' , "Root owns the ticket");
$t->Steal();
-ok ($t->OwnerObj->id eq $RT::SystemUser->id , "SystemUser owns the ticket");
+is ($t->OwnerObj->id, $RT::SystemUser->id , "SystemUser owns the ticket");
my $txns = RT::Transactions->new($RT::SystemUser);
$txns->OrderBy(FIELD => 'id', ORDER => 'DESC');
$txns->Limit(FIELD => 'Ticket', VALUE => '1');
@@ -3354,14 +3354,14 @@
my ($id, $tid, $msg)= $tt->Create(Queue => 'general',
Subject => 'test');
ok($id, $msg);
-ok($tt->Status eq 'new', "New ticket is created as new");
+is($tt->Status, 'new', "New ticket is created as new");
($id, $msg) = $tt->SetStatus('open');
ok($id, $msg);
-ok ($msg =~ /open/i, "Status message is correct");
+like($msg, qr/open/i, "Status message is correct");
($id, $msg) = $tt->SetStatus('resolved');
ok($id, $msg);
-ok ($msg =~ /resolved/i, "Status message is correct");
+like($msg, qr/resolved/i, "Status message is correct");
($id, $msg) = $tt->SetStatus('resolved');
ok(!$id,$msg);
Modified: rt/branches/rt-3.3/lib/RT/User_Overlay.pm
==============================================================================
--- rt/branches/rt-3.3/lib/RT/User_Overlay.pm (original)
+++ rt/branches/rt-3.3/lib/RT/User_Overlay.pm Sat Mar 20 10:40:58 2004
@@ -1093,7 +1093,7 @@
ok(my $u = RT::User->new($RT::SystemUser));
ok($u->Load(1), "Loaded the first user");
ok($u->PrincipalObj->ObjectId == 1, "user 1 is the first principal");
-ok($u->PrincipalObj->PrincipalType eq 'User' , "Principal 1 is a user, not a group");
+is($u->PrincipalObj->PrincipalType, 'User' , "Principal 1 is a user, not a group");
=end testing
@@ -1257,7 +1257,7 @@
my $new_tick2 = RT::Ticket->new($RT::SystemUser);
my ($tick2id, $tickmsg) = $new_tick2->Create(Subject=> 'ACL Test 2', Queue =>$q_as_system->Id);
ok($tick2id, "Created ticket: $tick2id");
-ok($new_tick2->QueueObj->id eq $q_as_system->Id, "Created a new ticket in queue 1");
+is($new_tick2->QueueObj->id, $q_as_system->Id, "Created a new ticket in queue 1");
# make sure that the user can't do this without subgroup membership
More information about the Rt-commit
mailing list