Newer
Older
require 'spec_helper'
describe 'deleteing your account' do
Ilya Zhitomirskiy
a validé
context "user" do
before do
@bob2 = bob
@person = @bob2.person
@alices_post = alice.post(:status_message, :text => "@{@bob2 Grimn; #{@bob2.person.diaspora_handle}} you are silly", :to => alice.aspects.find_by_name('generic'))
Ilya Zhitomirskiy
a validé
@bobs_contact_ids = @bob2.contacts.map {|c| c.id}
Ilya Zhitomirskiy
a validé
#@bob2's own content
@bob2.post(:status_message, :text => 'asldkfjs', :to => @bob2.aspects.first)
Ilya Zhitomirskiy
a validé
@aspect_vis = AspectVisibility.where(:aspect_id => @bob2.aspects.map(&:id))
danielgrippi
a validé
Ilya Zhitomirskiy
a validé
#objects on post
@bob2.comment!(@alices_post, "here are some thoughts on your post")
Ilya Zhitomirskiy
a validé
#conversations
create_conversation_with_message(alice, @bob2.person, "Subject", "Hey @bob2")
Ilya Zhitomirskiy
a validé
#join tables
@users_sv = ShareVisibility.where(:contact_id => @bobs_contact_ids).all
@persons_sv = ShareVisibility.where(:contact_id => bob.person.contacts.map(&:id)).all
Ilya Zhitomirskiy
a validé
#user associated objects
@prefs = []
%w{mentioned liked reshared}.each do |pref|
@prefs << @bob2.user_preferences.create!(:email_type => pref)
end
Ilya Zhitomirskiy
a validé
# notifications
@notifications = []
3.times do |n|
@notifications << FactoryGirl.create(:notification, :recipient => @bob2)
Ilya Zhitomirskiy
a validé
end
Ilya Zhitomirskiy
a validé
# services
@services = []
3.times do |n|
Ilya Zhitomirskiy
a validé
end
danielgrippi
a validé
Ilya Zhitomirskiy
a validé
# block
@block = @bob2.blocks.create!(:person => eve.person)
Ilya Zhitomirskiy
a validé
#authorization
Ilya Zhitomirskiy
a validé
AccountDeleter.new(@bob2.person.diaspora_handle).perform!
@bob2.reload
end
Ilya Zhitomirskiy
a validé
it "deletes all of the user's preferences" do
UserPreference.where(:id => @prefs.map{|pref| pref.id}).should be_empty
end
Ilya Zhitomirskiy
a validé
it "deletes all of the user's notifications" do
Notification.where(:id => @notifications.map{|n| n.id}).should be_empty
end
Ilya Zhitomirskiy
a validé
it "deletes all of the users's blocked users" do
Block.where(:id => @block.id).should be_empty
end
Ilya Zhitomirskiy
a validé
it "deletes all of the user's services" do
Service.where(:id => @services.map{|s| s.id}).should be_empty
end
Ilya Zhitomirskiy
a validé
it 'deletes all of @bob2s share visiblites' do
ShareVisibility.where(:id => @users_sv.map{|sv| sv.id}).should be_empty
ShareVisibility.where(:id => @persons_sv.map{|sv| sv.id}).should be_empty
end
danielgrippi
a validé
Ilya Zhitomirskiy
a validé
it 'deletes all of @bob2s aspect visiblites' do
AspectVisibility.where(:id => @aspect_vis.map(&:id)).should be_empty
end
Ilya Zhitomirskiy
a validé
it 'deletes all aspects' do
@bob2.aspects.should be_empty
end
Ilya Zhitomirskiy
a validé
it 'deletes all user contacts' do
@bob2.contacts.should be_empty
end
Ilya Zhitomirskiy
a validé
it "clears the account fields" do
@bob2.send(:clearable_fields).each do |field|
@bob2.reload[field].should be_blank
end
end
Ilya Zhitomirskiy
a validé
it_should_behave_like 'it removes the person associations'
danielgrippi
a validé
end
Ilya Zhitomirskiy
a validé
context 'remote person' do
before do
@person = remote_raphael
#contacts
@contacts = @person.contacts
#posts
@posts = (1..3).map do
Ilya Zhitomirskiy
a validé
end
@persons_sv = @posts.each do |post|
@contacts.each do |contact|
ShareVisibility.create!(:contact_id => contact.id, :shareable => post)
end
end
#photos
Ilya Zhitomirskiy
a validé
#mentions
@mentions = 3.times do
Ilya Zhitomirskiy
a validé
end
#conversations
create_conversation_with_message(alice, @person, "Subject", "Hey @bob2")
AccountDeleter.new(@person.diaspora_handle).perform!
@person.reload
end
Ilya Zhitomirskiy
a validé
it_should_behave_like 'it removes the person associations'