mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2010-04-21 10:54 pm

[dw-free] fix t/console-changejournaltype.t

[commit: http://hg.dwscoalition.org/dw-free/rev/8ca8d3daff8a]

http://bugs.dwscoalition.org/show_bug.cgi?id=2481

Fix change journal type console command for WTF and the test it rode in on.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/DW/User/Edges/WatchTrust.pm
  • cgi-bin/LJ/Console/Command/ChangeJournalType.pm
  • t/console-changejournaltype.t
--------------------------------------------------------------------------------
diff -r 3fa91526676e -r 8ca8d3daff8a cgi-bin/DW/User/Edges/WatchTrust.pm
--- a/cgi-bin/DW/User/Edges/WatchTrust.pm	Wed Apr 21 22:46:23 2010 +0000
+++ b/cgi-bin/DW/User/Edges/WatchTrust.pm	Wed Apr 21 22:54:39 2010 +0000
@@ -403,6 +403,17 @@ sub trusted_users {
 *LJ::User::trusted_users = \&trusted_users;
 
 
+# return users that trust you
+sub trusted_by_users {
+    my $u = $_[0];
+    my @trustids = $u->trusted_by_userids;
+    my $users = LJ::load_userids( @trustids );
+    return values %$users if wantarray;
+    return $users;
+}
+*LJ::User::trusted_by_users = \&trusted_by_users;
+
+
 # return users you watch
 sub watched_users {
     my $u = shift;
diff -r 3fa91526676e -r 8ca8d3daff8a cgi-bin/LJ/Console/Command/ChangeJournalType.pm
--- a/cgi-bin/LJ/Console/Command/ChangeJournalType.pm	Wed Apr 21 22:46:23 2010 +0000
+++ b/cgi-bin/LJ/Console/Command/ChangeJournalType.pm	Wed Apr 21 22:54:39 2010 +0000
@@ -32,7 +32,7 @@ sub usage { '<journal> <type> <owner> [f
 
 sub can_execute {
     my $remote = LJ::get_remote();
-    return ( $remote && $remote->has_priv( "changejournaltype" ) ) || $LJ::IS_DEV_SERVER;
+    return ( $remote && $remote->has_priv( "changejournaltype" ) );
 }
 
 sub execute {
@@ -110,14 +110,12 @@ sub execute {
     }
 
     #############################
-    # delete friend-ofs if we're changing to a person account. otherwise
+    # delete trusted-bys if we're changing to a person account. otherwise
     # the owner can log in and read those users' entries.
-    if ($type eq "person") {
-        my @ids = $u->friendof_uids;
-        $dbh->do("DELETE FROM friends WHERE friendid=?", undef, $u->id);
-
-        LJ::memcache_kill($_, "friends") foreach @ids;
-        LJ::memcache_kill($u, "friendofs");
+    if ( $type eq "person" ) {
+        foreach ( $u->trusted_by_users ) {
+            $_->remove_edge( $u, trust => { nonotify => 1 } ) ;
+        }
     }
 
     #############################
diff -r 3fa91526676e -r 8ca8d3daff8a t/console-changejournaltype.t
--- a/t/console-changejournaltype.t	Wed Apr 21 22:46:23 2010 +0000
+++ b/t/console-changejournaltype.t	Wed Apr 21 22:54:39 2010 +0000
@@ -7,7 +7,7 @@ use LJ::Test qw (temp_user temp_comm);
 use LJ::Test qw (temp_user temp_comm);
 local $LJ::T_NO_COMMAND_PRINT = 1;
 
-plan skip_all => 'Fix this test!';
+plan tests => 7;
 
 my $u = temp_user();
 my $u2 = temp_user();
--------------------------------------------------------------------------------
denise: Image: Me, facing away from camera, on top of the Castel Sant'Angelo in Rome (Default)

[staff profile] denise 2010-04-22 02:22 am (UTC)(link)
best commit message ever, y/n?