Author: kake Date: 2012-05-13 09:19:49 +0100 (Sun, 13 May 2012) New Revision: 1401
Modified: trunk/lib/OpenGuides/CGI.pm trunk/t/509_preferences.t trunk/templates/preferences.tt Log: Made preferences default to never expiring.
Modified: trunk/lib/OpenGuides/CGI.pm =================================================================== --- trunk/lib/OpenGuides/CGI.pm 2012-05-11 17:53:39 UTC (rev 1400) +++ trunk/lib/OpenGuides/CGI.pm 2012-05-13 08:19:49 UTC (rev 1401) @@ -341,7 +341,7 @@ # when that bug gets fixed show_minor_edits_in_rc => 1, default_edit_type => "normal", - cookie_expires => "month", + cookie_expires => "never", track_recent_changes_views => 0, display_google_maps => 1, is_admin => 0,
Modified: trunk/t/509_preferences.t =================================================================== --- trunk/t/509_preferences.t 2012-05-11 17:53:39 UTC (rev 1400) +++ trunk/t/509_preferences.t 2012-05-13 08:19:49 UTC (rev 1401) @@ -17,7 +17,7 @@ exit 0; }
-plan tests => 17; +plan tests => 21;
OpenGuides::Test::refresh_db();
@@ -96,6 +96,37 @@ "input", { type => "checkbox", name => "display_google_maps" }, "...but not when node maps are globally disabled." );
+# Make sure the default is for preferences to never expire. +delete $ENV{HTTP_COOKIE}; +$output = $guide->display_prefs_form( return_output => 1, noheaders => 1 ); +Test::HTML::Content::tag_ok( $output, + "option", { value => "never", "selected" => "1" }, + "Default for preferences expiry choice is "never"." ); + +$cookie = OpenGuides::CGI->make_prefs_cookie( config => $config, + cookie_expires => "never" ); +$ENV{HTTP_COOKIE} = $cookie; +$output = $guide->display_prefs_form( return_output => 1, noheaders => 1 ); +Test::HTML::Content::tag_ok( $output, + "option", { value => "never", "selected" => "1" }, + "...choice set to "never" if already set as such in cookie" ); + +$cookie = OpenGuides::CGI->make_prefs_cookie( config => $config, + cookie_expires => "year" ); +$ENV{HTTP_COOKIE} = $cookie; +$output = $guide->display_prefs_form( return_output => 1, noheaders => 1 ); +Test::HTML::Content::tag_ok( $output, + "option", { value => "year", "selected" => "1" }, + "...choice set to "year" if already set as such in cookie" ); + +$cookie = OpenGuides::CGI->make_prefs_cookie( config => $config, + cookie_expires => "month" ); +$ENV{HTTP_COOKIE} = $cookie; +$output = $guide->display_prefs_form( return_output => 1, noheaders => 1 ); +Test::HTML::Content::tag_ok( $output, + "option", { value => "month", "selected" => "1" }, + "...choice set to "month" if already set as such in cookie" ); + # Test JSON version of prefs page. my $json_writer = OpenGuides::JSON->new( wiki => $wiki, config => $config );
Modified: trunk/templates/preferences.tt =================================================================== --- trunk/templates/preferences.tt 2012-05-11 17:53:39 UTC (rev 1400) +++ trunk/templates/preferences.tt 2012-05-13 08:19:49 UTC (rev 1401) @@ -103,18 +103,18 @@ <p> <label for="cookie_expires">Preferences expire:</label> <select name="cookie_expires" id="cookie_expires"> - [% IF prefs.cookie_expires == 'never' %] - <option value="month">in one month</option> + [% IF prefs.cookie_expires == 'month' %] + <option value="month" selected="1">in one month</option> <option value="year">in one year</option> - <option value="never" selected="1">never</option> + <option value="never">never</option> [% ELSIF prefs.cookie_expires == "year" %] <option value="month">in one month</option> <option value="year" selected="1">in one year</option> <option value="never">never</option> [% ELSE %] - <option value="month" selected="1">in one month</option> + <option value="month">in one month</option> <option value="year">in one year</option> - <option value="never">never</option> + <option value="never" selected="1">never</option> [% END %] </select> </p>
openguides-commits@lists.openguides.org