Author: kake
Date: 2012-04-27 16:11:11 +0100 (Fri, 27 Apr 2012)
New Revision: 1368
Modified:
trunk/t/86_recent_changes.t
trunk/templates/recent_changes.tt
Log:
Make sure IP address is always shown for anonymous edits; also, don't try to show host
userstats for Auto Create.
Modified: trunk/t/86_recent_changes.t
===================================================================
--- trunk/t/86_recent_changes.t 2012-04-27 13:41:38 UTC (rev 1367)
+++ trunk/t/86_recent_changes.t 2012-04-27 15:11:11 UTC (rev 1368)
@@ -21,7 +21,7 @@
}
-plan tests => 10;
+plan tests => 14;
OpenGuides::Test::refresh_db();
@@ -158,3 +158,35 @@
local $TODO = "http://dev.openguides.org/ticket/270";
unlike ($output, qr/First edit/, "showing a page edit twice when not showing
minor edits");
}
+
+# Now write a node that will Auto Create a locale, and check the
+# Recent Changes output with minor edits and admin links switched on.
+# We can't use OG::Test->write_data() for this, because it calls
+# make_cgi_object(), which overwrites REMOTE_ADDR (and we want to test
+# output of IP address).
+$q = OpenGuides::Test->make_cgi_object();
+$q->param( -name => "username", -value => "Anonymous" );
+$q->param( -name => "locales", -value => "London" );
+my $test_host = "198.51.100.255";
+$ENV{REMOTE_ADDR} = $test_host;
+$guide->commit_node( id => "A Pub", cgi_obj => $q, return_output =>
1 );
+$ENV{HTTP_COOKIE} = OpenGuides::CGI->make_prefs_cookie(
+ config => $config, show_minor_edits_in_rc => 1, is_admin => 1 );
+$output = $guide->display_recent_changes( return_output => 1 );
+like( $output, qr|Auto\s+Create|,
+ "Auto Create stuff shown on Recent Changes." );
+unlike( $output, qr|host=;action=userstats|,
+ "...and no spurious link to host userstats" );
+
+# Make sure IP addresses always show up for anonymous edits.
+$ENV{HTTP_COOKIE} = OpenGuides::CGI->make_prefs_cookie(
+ config => $config, is_admin => 1 );
+$output = $guide->display_recent_changes( return_output => 1 );
+like( $output, qr|$test_host|,
+ "IP addresses show for anon edits when admin links switched on" );
+$ENV{HTTP_COOKIE} = OpenGuides::CGI->make_prefs_cookie(
+ config => $config, is_admin => 0 );
+$output = $guide->display_recent_changes( return_output => 1 );
+like( $output, qr|$test_host|,
+ "...also when admin links switched off" );
+
Modified: trunk/templates/recent_changes.tt
===================================================================
--- trunk/templates/recent_changes.tt 2012-04-27 13:41:38 UTC (rev 1367)
+++ trunk/templates/recent_changes.tt 2012-04-27 15:11:11 UTC (rev 1368)
@@ -48,10 +48,10 @@
[% END %]
[% IF (node.username != 'Anonymous') %]
<a href="[% cgi_url %]?username=[% node.username
%];action=userstats">[% node.username %]</a>
- [% IF is_admin %]
+ [% IF is_admin AND node.host %]
([% host_link %])
[% END %]
- [% ELSIF is_admin %]
+ [% ELSE %]
[% host_link %]
[% END %]
</span> [% IF node.comment %]- [% END %]<span
class="recentchanges_comment">[% node.comment %]</span>
Show replies by date