diaspora/spec/integration/account_deletion_spec.rb
Benjamin Neff 7ffd7878d0
Use person for AccountDeleter
Also remove `disconnect_contacts` methods, because contacts are already
removed with aspects memberships in `before_destroy`.
2017-08-13 20:10:07 +02:00

45 lines
1.7 KiB
Ruby

describe "deleteing account", type: :request do
def account_removal_method
AccountDeleter.new(person).perform!
subject.reload
end
context "of local user" do
subject(:user) { FactoryGirl.create(:user_with_aspect) }
let(:person) { user.person }
before do
DataGenerator.create(subject, :generic_user_data)
end
it "deletes all of the user data" do
expect {
account_removal_method
}.to change(nil, "user preferences empty?") { UserPreference.where(user_id: user.id).empty? }.to(be_truthy)
.and(change(nil, "notifications empty?") { Notification.where(recipient_id: user.id).empty? }.to(be_truthy))
.and(change(nil, "blocks empty?") { Block.where(user_id: user.id).empty? }.to(be_truthy))
.and(change(nil, "services empty?") { Service.where(user_id: user.id).empty? }.to(be_truthy))
.and(change(nil, "share visibilities empty?") { ShareVisibility.where(user_id: user.id).empty? }.to(be_truthy))
.and(change(nil, "aspects empty?") { user.aspects.empty? }.to(be_truthy))
.and(change(nil, "contacts empty?") { user.contacts.empty? }.to(be_truthy))
.and(change(nil, "tag followings empty?") { user.tag_followings.empty? }.to(be_truthy))
.and(change(nil, "clearable fields blank?") {
user.send(:clearable_fields).map {|field|
user.reload[field].blank?
}
}.to(eq([true] * user.send(:clearable_fields).count)))
end
it_behaves_like "it removes the person associations"
end
context "of remote person" do
subject(:person) { remote_raphael }
before do
DataGenerator.create(subject, :generic_person_data)
end
it_behaves_like "it removes the person associations"
end
end