[Rt-commit] rt branch, 4.0/refresh-lang-pref-fix, created. rt-4.0.8-305-gf23830b

? sunnavy sunnavy at bestpractical.com
Fri Dec 28 09:07:39 EST 2012


The branch, 4.0/refresh-lang-pref-fix has been created
        at  f23830b2fddf40c7f3fc717d1e1caa150eac1ff1 (commit)

- Log -----------------------------------------------------------------
commit 8918040df9641b9cfc615b43b1ea22bbc51b2804
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu May 24 02:01:24 2012 +0800

    update lang preference even if lang is empty(a.k.a system default)
    
    without this fix, page won't be be updated correctly if user switches back to
    system default language.
    
    checking defined-ness of $Lang instead of throwing the "if" away is to avoid
    warnings from I18n::LangTags when $Lang is undef, which happens upon loading
    the user preferences page.(thanks to chmrr++)

diff --git a/share/html/User/Prefs.html b/share/html/User/Prefs.html
index 5595f23..42095d4 100644
--- a/share/html/User/Prefs.html
+++ b/share/html/User/Prefs.html
@@ -247,7 +247,7 @@ else {
 
     push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
 
-    if ( $Lang ) {
+    if ( defined $Lang ) {
         $session{'CurrentUser'}->LanguageHandle($Lang);
         $session{'CurrentUser'} = $session{'CurrentUser'}; # force writeback
     }

commit b97002368656f58d4b0a8ffeb600c39e2600dc4b
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Dec 26 23:37:55 2012 -0500

    Add tests for changing language to the default

diff --git a/t/web/user_update.t b/t/web/user_update.t
index d5751ab..5440b84 100644
--- a/t/web/user_update.t
+++ b/t/web/user_update.t
@@ -1,16 +1,14 @@
 use strict;
 use warnings;
 use utf8;
-use RT::Test tests => 9;
+use RT::Test tests => undef;
 
 my ( $url, $m ) = RT::Test->started_ok;
 ok( $m->login(), 'logged in' );
 
 $m->follow_link_ok({text => 'About me'});
-$m->form_with_fields('Lang');
-$m->field(Lang => 'ja');
-$m->submit;
-
+$m->submit_form_ok({ with_fields => { Lang => 'ja'} },
+               "Change to Japanese");
 $m->text_contains("Lang changed from (no value) to 'ja'");
 
 # we only changed one field, and it wasn't the default, so this feedback is
@@ -18,14 +16,24 @@ $m->text_contains("Lang changed from (no value) to 'ja'");
 $m->content_lacks("That is already the current value");
 
 # change back to English
-$m->form_with_fields('Lang');
-$m->field(Lang => 'en_us');
-$m->submit;
+$m->submit_form_ok({ with_fields => { Lang => 'en_us'} },
+               "Change back to english");
 
 # This message shows up in Japanese
 # $m->text_contains("Lang changed from 'ja' to 'en_us'");
 $m->text_contains("Langは「'ja'」から「'en_us'」に変更されました");
 
-# another spurious update
+# Check for a lack of spurious updates
 $m->content_lacks("That is already the current value");
 
+# Ensure that we can change the language back to the default.
+$m->submit_form_ok({ with_fields => { Lang => 'ja'} },
+                   "Back briefly to Japanese");
+$m->text_contains("Lang changed from 'en_us' to 'ja'");
+$m->submit_form_ok({ with_fields => { Lang => ''} },
+                   "And set to the default");
+$m->text_contains("Langは「'ja'」から「''」に変更されました");
+
+undef $m;
+
+done_testing;

commit f23830b2fddf40c7f3fc717d1e1caa150eac1ff1
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Dec 28 22:05:08 2012 +0800

    initialize LangHandle on each request to make it up to date too

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 3295c0d..6aae7f5 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -266,6 +266,7 @@ sub HandleRequest {
         # make user info up to date
         $HTML::Mason::Commands::session{'CurrentUser'}
           ->Load( $HTML::Mason::Commands::session{'CurrentUser'}->id );
+        undef $HTML::Mason::Commands::session{'CurrentUser'}->{'LangHandle'};
     }
     else {
         $HTML::Mason::Commands::session{'CurrentUser'} = RT::CurrentUser->new();

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


More information about the Rt-commit mailing list