adds specs

This commit is contained in:
rgarcia
2016-12-08 14:04:23 +01:00
parent b12c8d3a5d
commit 39fd031780

View File

@@ -415,18 +415,18 @@ describe User do
end
describe "#erase" do
it "anonymizes a user and marks him as hidden" do
it "erases user information and marks him as erased" do
user = create(:user,
username: "manolo",
email: "a@a.com",
unconfirmed_email: "a@a.com",
document_number: "1234",
phone_number: "5678",
confirmed_phone: "5678",
unconfirmed_phone: "5678",
encrypted_password: "foobar",
confirmation_token: "token1",
reset_password_token: "token2",
email_verification_token: "token3",
confirmed_phone:"5678",
unconfirmed_phone:"5678")
email_verification_token: "token3")
user.erase('a test')
user.reload
@@ -435,28 +435,38 @@ describe User do
expect(user.erased_at).to be
expect(user.username).to be_nil
expect(user.email).to be_nil
expect(user.unconfirmed_email).to be_nil
expect(user.document_number).to be_nil
expect(user.phone_number).to be_nil
expect(user.confirmed_phone).to be_nil
expect(user.unconfirmed_phone).to be_nil
expect(user.encrypted_password).to be_empty
expect(user.confirmation_token).to be_nil
expect(user.reset_password_token).to be_nil
expect(user.email_verification_token).to be_nil
end
it "destroys associated identities" do
it "maintains associated identification document" do
user = create(:user,
document_number: "1234",
document_type: "1")
user.erase
user.reload
expect(user.erased_at).to be
expect(user.document_number).to be
expect(user.document_type).to be
end
it "destroys associated social network identities" do
user = create(:user)
identity = create(:identity, user: user)
user.erase('an identity test')
expect(Identity.exists?(identity.id)).to_not be
end
end
end
end