Tweak behavior, for the sake of tests. Good enough patch for now.
Patch by fu.
diffs (45 lines):
diff -r 1a5c54e5fd7b -r 27e14284313c cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm Tue Jan 11 11:59:28 2011 +0800
+++ b/cgi-bin/LJ/User.pm Thu Jan 13 11:55:17 2011 +0800
@@ -2335,7 +2335,9 @@ sub exclude_from_own_stats {
# the user is a member of
sub get_cap {
my ( $u, $cname ) = @_;
- return 1 if $LJ::T_HAS_ALL_CAPS;
+
+ # turn on all caps for tests, except the read-only cap
+ return 1 if $LJ::T_HAS_ALL_CAPS && $cname ne "readonly";
return LJ::get_cap( $u, $cname );
}
diff -r 1a5c54e5fd7b -r 27e14284313c t/caps.t
--- a/t/caps.t Tue Jan 11 11:59:28 2011 +0800
+++ b/t/caps.t Thu Jan 13 11:55:17 2011 +0800
@@ -1,9 +1,10 @@
# -*-perl-*-
use strict;
-use Test::More 'no_plan';
+use Test::More tests => 4;
use lib "$ENV{LJHOME}/cgi-bin";
require 'ljlib.pl';
+use LJ::Test qw( temp_user );
{
my $c;
@@ -13,6 +14,15 @@ require 'ljlib.pl';
$c = eval { LJ::get_cap(undef, 'can_post') };
is($c, 1, "Undef returns default");
+
+
+ my $u = temp_user();
+ $LJ::T_HAS_ALL_CAPS = 1;
+ $c = eval { $u->get_cap( 'anycapatall' ) };
+ ok( $c, "Cap always on" );
+
+ $c = eval { $u->get_cap( 'readonly' ) };
+ ok( ! $c, "readonly cap is not automatically set enabled" );
}
1;
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog