refactor adminCreateContribution to check for deleted users

This commit is contained in:
Ulf Gebhardt 2023-02-06 22:30:23 +01:00
parent 3724295b6f
commit 225652ecc7
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
3 changed files with 8 additions and 9 deletions

View File

@ -1633,7 +1633,11 @@ describe('ContributionResolver', () => {
it('logs the error thrown', () => {
expect(logger.error).toBeCalledWith(
'Cannot create contribution since the user was deleted',
expect.objectContaining({ deletedAt: new Date('2018-03-14T09:17:52.000Z') }),
expect.objectContaining({
user: expect.objectContaining({
deletedAt: new Date('2018-03-14T09:17:52.000Z'),
}),
}),
)
})
})

View File

@ -307,14 +307,8 @@ export class ContributionResolver {
if (!emailContact) {
throw new LogError('Could not find user', email)
}
if (emailContact.deletedAt) {
throw new LogError(
'Cannot create contribution since the emailContact was deleted',
emailContact,
)
}
if (emailContact.user.deletedAt) {
throw new LogError('Cannot create contribution since the user was deleted', emailContact.user)
if (emailContact.deletedAt || emailContact.user.deletedAt) {
throw new LogError('Cannot create contribution since the user was deleted', emailContact)
}
if (!emailContact.emailChecked) {
throw new LogError(

View File

@ -1,5 +1,6 @@
import { UserInterface } from './UserInterface'
// TODO: the generated email_contact is not deleted
export const stephenHawking: UserInterface = {
email: 'stephen@hawking.uk',
firstName: 'Stephen',