[Rt-commit] rt branch, 4.0/current-user-outdated-email-name-fix, created. rt-4.0.6-220-g87a8494

Alex Vandiver alexmv at bestpractical.com
Wed Jun 20 20:08:31 EDT 2012


The branch, 4.0/current-user-outdated-email-name-fix has been created
        at  87a8494c7683cbc0a6a8ddc8b94a3c004d096073 (commit)

- Log -----------------------------------------------------------------
commit 3d790a268916de72dd67bced7ca1c10fad001fef
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed May 25 10:32:01 2011 +0800

    load current user on every request to keep the info up to date

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 91c8ff2..748caa3 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -261,7 +261,15 @@ sub HandleRequest {
 
     $HTML::Mason::Commands::m->comp( '/Elements/SetupSessionCookie', %$ARGS );
     SendSessionCookie();
-    $HTML::Mason::Commands::session{'CurrentUser'} = RT::CurrentUser->new() unless _UserLoggedIn();
+
+    if ( _UserLoggedIn() ) {
+        # make user info up to date
+        $HTML::Mason::Commands::session{'CurrentUser'}
+          ->Load( $HTML::Mason::Commands::session{'CurrentUser'}->id );
+    }
+    else {
+        $HTML::Mason::Commands::session{'CurrentUser'} = RT::CurrentUser->new();
+    }
 
     # Process session-related callbacks before any auth attempts
     $HTML::Mason::Commands::m->callback( %$ARGS, CallbackName => 'Session', CallbackPage => '/autohandler' );

commit bbcd1d812a03d130f0bec8656305a89847493593
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed May 25 11:05:19 2011 +0800

    use CurrentUser->EmailAddress consistently

diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index 8f38d99..2594e99 100644
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -787,7 +787,7 @@ sub GetForwardFrom {
     my $ticket = $args{Ticket} || $txn->Object;
 
     if ( RT->Config->Get('ForwardFromUser') ) {
-        return ( $txn || $ticket )->CurrentUser->UserObj->EmailAddress;
+        return ( $txn || $ticket )->CurrentUser->EmailAddress;
     }
     else {
         return $ticket->QueueObj->CorrespondAddress
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 306ad4a..3c7eac9 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -1058,7 +1058,7 @@ sub AddWatcher {
         return (0, $self->loc("Couldn't parse address from '[_1]' string", $args{'Email'} ))
             unless $addr;
 
-        if ( lc $self->CurrentUser->UserObj->EmailAddress
+        if ( lc $self->CurrentUser->EmailAddress
             eq lc RT::User->CanonicalizeEmailAddress( $addr->address ) )
         {
             $args{'PrincipalId'} = $self->CurrentUser->id;
diff --git a/share/html/Approvals/Elements/PendingMyApproval b/share/html/Approvals/Elements/PendingMyApproval
index d2061da..169c25c 100755
--- a/share/html/Approvals/Elements/PendingMyApproval
+++ b/share/html/Approvals/Elements/PendingMyApproval
@@ -74,7 +74,7 @@ $tickets->LimitOwner( VALUE => $session{'CurrentUser'}->Id );
 
 # also consider AdminCcs as potential approvers.
 my $group_tickets = RT::Tickets->new( $session{'CurrentUser'} );
-$group_tickets->LimitWatcher( VALUE => $session{'CurrentUser'}->UserObj->EmailAddress, TYPE => 'AdminCc' );
+$group_tickets->LimitWatcher( VALUE => $session{'CurrentUser'}->EmailAddress, TYPE => 'AdminCc' );
 
 my $created_before = RT::Date->new( $session{'CurrentUser'} );
 my $created_after = RT::Date->new( $session{'CurrentUser'} );
diff --git a/share/html/Dashboards/Subscription.html b/share/html/Dashboards/Subscription.html
index 3669e46..3a57102 100644
--- a/share/html/Dashboards/Subscription.html
+++ b/share/html/Dashboards/Subscription.html
@@ -171,7 +171,7 @@
 <&|/l&>Recipient</&>:
 </td><td class="value">
 <input name="Recipient" id="Recipient" size="30" value="<%$fields{Recipient} ? $fields{Recipient} : ''%>" />
-<div class="hints"><% loc("Leave blank to send to your current email address ([_1])", $session{'CurrentUser'}->UserObj->EmailAddress) %></div>
+<div class="hints"><% loc("Leave blank to send to your current email address ([_1])", $session{'CurrentUser'}->EmailAddress) %></div>
 </td></tr>
 </table>
 </&>

commit a9e53426c73b1a128911e8c551a0d553962b8b30
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue May 24 15:16:10 2011 +0800

    extra query support so we can set Requestors, Subject, etc via url

diff --git a/lib/RT/Test/Web.pm b/lib/RT/Test/Web.pm
index c2d9ac3..523edc8 100644
--- a/lib/RT/Test/Web.pm
+++ b/lib/RT/Test/Web.pm
@@ -158,6 +158,8 @@ sub goto_ticket {
 sub goto_create_ticket {
     my $self = shift;
     my $queue = shift;
+    my $query = shift || '';
+    $query = '&' . $query if $query && $query !~ /^&/;
 
     my $id;
     if ( ref $queue ) {
@@ -168,7 +170,8 @@ sub goto_create_ticket {
         die "not yet implemented";
     }
 
-    $self->get($self->rt_base_url . 'Ticket/Create.html?Queue='.$id);
+    $self->get(
+        $self->rt_base_url . 'Ticket/Create.html?Queue=' . $id . $query );
 
     return 1;
 }

commit 6c831de8702bf3b5afe320637759b5ec100e5c48
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue May 24 15:19:14 2011 +0800

    set Requestors explicitly since now we use user's up to date email

diff --git a/t/web/crypt-gnupg.t b/t/web/crypt-gnupg.t
index 6bdefda..ab1e62f 100644
--- a/t/web/crypt-gnupg.t
+++ b/t/web/crypt-gnupg.t
@@ -51,7 +51,7 @@ $m->submit;
 
 RT::Test->clean_caught_mails;
 
-$m->goto_create_ticket( $queue );
+$m->goto_create_ticket( $queue, 'Requestors=recipient at example.com' );
 $m->form_name('TicketCreate');
 $m->field('Subject', 'Encryption test');
 $m->field('Content', 'Some content');
@@ -120,7 +120,7 @@ $m->submit;
 
 RT::Test->clean_caught_mails;
 
-$m->goto_create_ticket( $queue );
+$m->goto_create_ticket( $queue, 'Requestors=recipient at example.com' );
 $m->form_name('TicketCreate');
 $m->field('Subject', 'Signing test');
 $m->field('Content', 'Some other content');
@@ -193,7 +193,7 @@ $m->submit;
 RT::Test->clean_caught_mails;
 
 
-$m->goto_create_ticket( $queue );
+$m->goto_create_ticket( $queue, 'Requestors=recipient at example.com' );
 $m->form_name('TicketCreate');
 $m->field('Subject', 'Crypt+Sign test');
 $m->field('Content', 'Some final? content');
@@ -258,7 +258,7 @@ MAIL
 
 RT::Test->clean_caught_mails;
 
-$m->goto_create_ticket( $queue );
+$m->goto_create_ticket( $queue, 'Requestors=recipient at example.com' );
 $m->form_name('TicketCreate');
 $m->field('Subject', 'Test crypt-off on encrypted queue');
 $m->field('Content', 'Thought you had me figured out didya');

commit 87a8494c7683cbc0a6a8ddc8b94a3c004d096073
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue May 24 16:06:02 2011 +0800

    test for updated email of current user

diff --git a/t/web/current_user_outdated_email.t b/t/web/current_user_outdated_email.t
new file mode 100644
index 0000000..51fc803
--- /dev/null
+++ b/t/web/current_user_outdated_email.t
@@ -0,0 +1,41 @@
+
+use strict;
+use warnings;
+use RT::Test tests => 39;
+
+my ( $url, $m ) = RT::Test->started_ok;
+
+$m->login();
+
+my @links = (
+    '/',                                '/Ticket/Create.html?Queue=1',
+    '/SelfService/Create.html?Queue=1', '/m/ticket/create?Queue=1'
+);
+
+my $root = RT::Test->load_or_create_user( Name => 'root' );
+ok( $root->id, 'loaded root' );
+is( $root->EmailAddress, 'root at localhost', 'default root email' );
+
+for my $link (@links) {
+    $m->get_ok($link);
+    $m->content_contains( '"root at localhost"', "default email in $link" );
+}
+
+$root->SetEmailAddress('foo at example.com');
+is( $root->EmailAddress, 'foo at example.com', 'changed to foo at example.com' );
+
+for my $link (@links) {
+    $m->get_ok($link);
+    $m->content_lacks( '"root at localhost"', "no default email in $link" );
+    $m->content_contains( '"foo at example.com"', "new email in $link" );
+}
+
+$root->SetEmailAddress('root at localhost');
+is( $root->EmailAddress, 'root at localhost', 'changed back to root at localhost' );
+
+for my $link (@links) {
+    $m->get_ok($link);
+    $m->content_lacks( '"foo at example.com"', "no previous email in $link" );
+    $m->content_contains( '"root at localhost"', "default email in $link" );
+}
+

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


More information about the Rt-commit mailing list