mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
do not allow edit contribution for admin contributions in backend
This commit is contained in:
parent
d3ac556885
commit
695d037a2d
@ -2042,6 +2042,50 @@ describe('ContributionResolver', () => {
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
describe('user tries to update admin contribution', () => {
|
||||
beforeAll(async () => {
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
|
||||
it('logs and throws "Cannot update contribution of moderator" error', async () => {
|
||||
jest.clearAllMocks()
|
||||
const adminContribution = await Contribution.findOne({
|
||||
where: {
|
||||
moderatorId: admin.id,
|
||||
userId: bibi.id,
|
||||
},
|
||||
})
|
||||
await expect(
|
||||
mutate({
|
||||
mutation: updateContribution,
|
||||
variables: {
|
||||
contributionId: (adminContribution && adminContribution.id) || -1,
|
||||
amount: 100.0,
|
||||
memo: 'Test Test Test',
|
||||
creationDate: new Date().toString(),
|
||||
},
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
errors: [new GraphQLError('Cannot update contribution of moderator')],
|
||||
})
|
||||
expect(logger.error).toBeCalledWith(
|
||||
'Cannot update contribution of moderator',
|
||||
expect.any(Object),
|
||||
bibi.id,
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('second creation surpasses the available amount ', () => {
|
||||
|
||||
@ -201,6 +201,9 @@ export class ContributionResolver {
|
||||
user.id,
|
||||
)
|
||||
}
|
||||
if (contributionToUpdate.moderatorId) {
|
||||
throw new LogError('Cannot update contribution of moderator', contributionToUpdate, user.id)
|
||||
}
|
||||
if (
|
||||
contributionToUpdate.contributionStatus !== ContributionStatus.IN_PROGRESS &&
|
||||
contributionToUpdate.contributionStatus !== ContributionStatus.PENDING
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user