Author: ilmari Date: 2007-06-09 20:10:30 +0100 (Sat, 09 Jun 2007) New Revision: 1050
Added: trunk/t/59_preferences.t Modified: trunk/Changes trunk/MANIFEST trunk/templates/preferences.tt Log: Only display the google maps preference if node maps are enabled (fixes #192)
Modified: trunk/Changes =================================================================== --- trunk/Changes 2007-06-09 18:46:46 UTC (rev 1049) +++ trunk/Changes 2007-06-09 19:10:30 UTC (rev 1050) @@ -11,6 +11,8 @@ Removed dependency on Test::MockObject. Remove misleading CSS examples Support alternative database ports + Only display the google maps preference if node maps are enabled + (#192).
0.60 13 May 2007 Removed footer search from edit page (shouldn't have been there).
Modified: trunk/MANIFEST =================================================================== --- trunk/MANIFEST 2007-06-09 18:46:46 UTC (rev 1049) +++ trunk/MANIFEST 2007-06-09 19:10:30 UTC (rev 1050) @@ -122,6 +122,7 @@ t/56_diffs_with_macros.t t/57_random_page.t t/58_recent_changes_navbar.t +t/59_preferences.t t/61_bug_textareas.t t/62_bug_trailing_whitespace.t t/63_bug_map_link_no_address.t
Added: trunk/t/59_preferences.t =================================================================== --- trunk/t/59_preferences.t (rev 0) +++ trunk/t/59_preferences.t 2007-06-09 19:10:30 UTC (rev 1050) @@ -0,0 +1,69 @@ +use Wiki::Toolkit::Setup::SQLite; +use OpenGuides; +use OpenGuides::Test; +use Test::More; + +eval { require DBD::SQLite; }; + +if ( $@ ) { + my ($error) = $@ =~ /^(.*?)\n/; + plan skip_all => "DBD::SQLite could not be used - no database to test with ($error)"; +} + +eval { require DBD::SQLite; }; +if ( $@ ) { + plan skip_all => "DBD::SQLite not installed - no database to test with"; + exit 0; +} + +eval { require Test::HTML::Content; }; +if ( $@ ) { + plan skip_all => "Test::HTML::Content not installed"; + exit 0; +} + +plan tests => 2; + +Wiki::Toolkit::Setup::SQLite::cleardb( { dbname => "t/prefs.db" } ); +Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/prefs.db" } ); +my $config = OpenGuides::Test->make_basic_config; +my $guide = OpenGuides->new( config => $config ); +my $wiki = $guide->wiki; + +$config->gmaps_api_key( "This is not a real API key." ); +$config->show_gmap_in_node_display( 1 ); + +my $cookie = OpenGuides::CGI->make_prefs_cookie( + config => $config, + display_google_maps => 1, + ); +$ENV{HTTP_COOKIE} = $cookie; + +# If the google API is present and node maps are enabled, we should have the pref +Test::HTML::Content::tag_ok( get_output($wiki, $config), 'input', + { type => 'checkbox', name => 'display_google_maps' }, + 'Google maps pref shown' + ); + +# But not if the node map is globally disabled +$config->show_gmap_in_node_display( 0 ); +Test::HTML::Content::no_tag( get_output($wiki, $config), 'input', + { type => 'checkbox', name => 'display_google_maps' }, + 'No google maps prefs if node maps disabled' + ); + +sub get_output { + my ($wiki, $config) = @_; + + return OpenGuides::Template->output( + wiki => $wiki, + config => $config, + template => "preferences.tt", + content_type => '', + vars => { OpenGuides::CGI->get_prefs_from_cookie( config => $config ), + not_editable => 1, + show_form => 1 + }, + ); +} +
Modified: trunk/templates/preferences.tt =================================================================== --- trunk/templates/preferences.tt 2007-06-09 18:46:46 UTC (rev 1049) +++ trunk/templates/preferences.tt 2007-06-09 19:10:30 UTC (rev 1050) @@ -66,7 +66,7 @@ <label for="track_recent_changes_views">Track my visits to Recent Changes and offer me a link for “changes since I last viewed Recent Changes”.</label> </p>
- [% IF gmaps_api_key %] + [% IF gmaps_api_key AND config.show_gmap_in_node_display %] <p> [% IF display_google_maps %] <input type="checkbox" id="display_google_maps" name="display_google_maps" value="1" checked="1" /> @@ -152,7 +152,7 @@ [% UNLESS track_recent_changes_views %] not [% END %] be tracked.</p>
- [% IF gmaps_api_key %] + [% IF gmaps_api_key AND config.show_gmap_in_node_display %] <p>Google Maps will [% UNLESS display_google_maps %] not [% END %] be displayed.</p>