i think this works
This commit is contained in:
parent
0bd101dca9
commit
f800d50a2b
5 changed files with 23 additions and 11 deletions
|
|
@ -81,7 +81,6 @@ class UsersController < ApplicationController
|
|||
|
||||
def destroy
|
||||
if params[:user] && params[:user][:current_password] && current_user.valid_password?(params[:user][:current_password])
|
||||
Resque.enqueue(Jobs::DeleteAccount, current_user.id)
|
||||
current_user.close_account!
|
||||
sign_out current_user
|
||||
flash[:notice] = I18n.t 'users.destroy.success'
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ class AccountDeletion < ActiveRecord::Base
|
|||
|
||||
xml_attr :diaspora_handle
|
||||
|
||||
|
||||
def person=(person)
|
||||
self[:diaspora_handle] = person.diaspora_handle
|
||||
self[:person_id] = person.id
|
||||
|
|
@ -37,10 +36,14 @@ class AccountDeletion < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def subscribers(user)
|
||||
person.owner.contact_people | Person.who_have_reshared_a_users_posts(person.owner)
|
||||
person.owner.contact_people.remote | Person.who_have_reshared_a_users_posts(person.owner).remote
|
||||
end
|
||||
|
||||
def dispatch
|
||||
Postzord::Dispatcher.build(person.owner, self).post
|
||||
end
|
||||
|
||||
def public?
|
||||
true
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -490,9 +490,9 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def close_account!
|
||||
AccountDeletion.create(:person => self.person)
|
||||
self.person.lock_access!
|
||||
self.lock_access!
|
||||
AccountDeletion.create(:person => self.person)
|
||||
end
|
||||
|
||||
def clear_account!
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ class Postzord::Receiver::Public < Postzord::Receiver
|
|||
|
||||
if @object.respond_to?(:relayable?)
|
||||
receive_relayable
|
||||
elsif @object.is_a?(AccountDeletion)
|
||||
#nothing
|
||||
else
|
||||
Resque.enqueue(Jobs::ReceiveLocalBatch, @object.class.to_s, @object.id, self.recipient_user_ids)
|
||||
true
|
||||
|
|
|
|||
|
|
@ -42,22 +42,30 @@ describe AccountDeletion do
|
|||
it "sends the account deletion xml" do
|
||||
@ad = AccountDeletion.new(:person => alice.person)
|
||||
@ad.send(:dispatch)
|
||||
end
|
||||
|
||||
it 'creates a public postzord' do
|
||||
Postzord::Dispatcher::Public.should_receive(:new).and_return(stub.as_null_object)
|
||||
@ad = AccountDeletion.new(:person => alice.person)
|
||||
@ad.send(:dispatch)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#subscribers" do
|
||||
it 'includes all contacts' do
|
||||
it 'includes all remote contacts' do
|
||||
@ad = AccountDeletion.new(:person => alice.person)
|
||||
@ad.person.owner.should_receive(:contact_people).and_return([remote_raphael])
|
||||
@ad.subscribers(alice).should include(remote_raphael)
|
||||
alice.share_with(remote_raphael, alice.aspects.first)
|
||||
|
||||
@ad.subscribers(alice).should == [remote_raphael]
|
||||
end
|
||||
|
||||
it 'includes resharers' do
|
||||
it 'includes remote resharers' do
|
||||
@ad = AccountDeletion.new(:person => alice.person)
|
||||
p = Factory(:person)
|
||||
Person.should_receive(:who_have_reshared_a_users_posts).with(alice).and_return([p])
|
||||
@ad.subscribers(alice).should include(p)
|
||||
sm = Factory( :status_message, :public => true, :author => alice.person)
|
||||
r1 = Factory( :reshare, :author => remote_raphael, :root => sm)
|
||||
r2 = Factory( :reshare, :author => local_luke.person, :root => sm)
|
||||
|
||||
@ad.subscribers(alice).should == [remote_raphael]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue