diaspora/spec/integration/account_deletion_spec.rb
cmrd Senya 7db4f825a6
Refactor account deletion spec
This commit refactors account deletion spec by moving data creation to a helper
object DataGenerator.
2017-08-09 18:09:04 +03:00

46 lines
1.8 KiB
Ruby

describe "deleteing account", type: :request do
def account_removal_method
AccountDeleter.new(subject.diaspora_handle).perform!
subject.reload
end
context "of local user" do
subject(:user) { FactoryGirl.create(:user_with_aspect) }
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" do
subject(:person) { user.person }
end
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