mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
rename confirmPendingCreation
This commit is contained in:
parent
dd04f69ecc
commit
2b87cbcd18
7
admin/src/graphql/confirmContribution.js
Normal file
7
admin/src/graphql/confirmContribution.js
Normal file
@ -0,0 +1,7 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const confirmContribution = gql`
|
||||
mutation ($id: Int!) {
|
||||
confirmContribution(id: $id)
|
||||
}
|
||||
`
|
||||
@ -1,7 +0,0 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const confirmPendingCreation = gql`
|
||||
mutation ($id: Int!) {
|
||||
confirmPendingCreation(id: $id)
|
||||
}
|
||||
`
|
||||
@ -1,7 +1,7 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import CreationConfirm from './CreationConfirm.vue'
|
||||
import { adminDeleteContribution } from '../graphql/adminDeleteContribution'
|
||||
import { confirmPendingCreation } from '../graphql/confirmPendingCreation'
|
||||
import { confirmContribution } from '../graphql/confirmContribution'
|
||||
import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup'
|
||||
|
||||
const localVue = global.localVue
|
||||
@ -141,9 +141,9 @@ describe('CreationConfirm', () => {
|
||||
await wrapper.find('#overlay').findAll('button').at(1).trigger('click')
|
||||
})
|
||||
|
||||
it('calls the confirmPendingCreation mutation', () => {
|
||||
it('calls the confirmContribution mutation', () => {
|
||||
expect(apolloMutateMock).toBeCalledWith({
|
||||
mutation: confirmPendingCreation,
|
||||
mutation: confirmContribution,
|
||||
variables: { id: 2 },
|
||||
})
|
||||
})
|
||||
|
||||
@ -17,7 +17,7 @@ import Overlay from '../components/Overlay.vue'
|
||||
import OpenCreationsTable from '../components/Tables/OpenCreationsTable.vue'
|
||||
import { listUnconfirmedContributions } from '../graphql/listUnconfirmedContributions'
|
||||
import { adminDeleteContribution } from '../graphql/adminDeleteContribution'
|
||||
import { confirmPendingCreation } from '../graphql/confirmPendingCreation'
|
||||
import { confirmContribution } from '../graphql/confirmContribution'
|
||||
|
||||
export default {
|
||||
name: 'CreationConfirm',
|
||||
@ -52,7 +52,7 @@ export default {
|
||||
confirmCreation() {
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: confirmPendingCreation,
|
||||
mutation: confirmContribution,
|
||||
variables: {
|
||||
id: this.item.id,
|
||||
},
|
||||
|
||||
@ -32,7 +32,7 @@ export enum RIGHTS {
|
||||
ADMIN_UPDATE_CONTRIBUTION = 'ADMIN_UPDATE_CONTRIBUTION',
|
||||
ADMIN_DELETE_CONTRIBUTION = 'ADMIN_DELETE_CONTRIBUTION',
|
||||
LIST_UNCONFIRMED_CONTRIBUTIONS = 'LIST_UNCONFIRMED_CONTRIBUTIONS',
|
||||
CONFIRM_PENDING_CREATION = 'CONFIRM_PENDING_CREATION',
|
||||
CONFIRM_CONTRIBUTION = 'CONFIRM_CONTRIBUTION',
|
||||
SEND_ACTIVATION_EMAIL = 'SEND_ACTIVATION_EMAIL',
|
||||
DELETE_USER = 'DELETE_USER',
|
||||
UNDELETE_USER = 'UNDELETE_USER',
|
||||
|
||||
@ -19,7 +19,7 @@ import {
|
||||
adminCreateContributions,
|
||||
updatePendingCreation,
|
||||
adminDeleteContribution,
|
||||
confirmPendingCreation,
|
||||
confirmContribution,
|
||||
createContributionLink,
|
||||
deleteContributionLink,
|
||||
updateContributionLink,
|
||||
@ -579,11 +579,11 @@ describe('AdminResolver', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('confirmPendingCreation', () => {
|
||||
describe('confirmContribution', () => {
|
||||
it('returns an error', async () => {
|
||||
await expect(
|
||||
mutate({
|
||||
mutation: confirmPendingCreation,
|
||||
mutation: confirmContribution,
|
||||
variables: {
|
||||
id: 1,
|
||||
},
|
||||
@ -689,11 +689,11 @@ describe('AdminResolver', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('confirmPendingCreation', () => {
|
||||
describe('confirmContribution', () => {
|
||||
it('returns an error', async () => {
|
||||
await expect(
|
||||
mutate({
|
||||
mutation: confirmPendingCreation,
|
||||
mutation: confirmContribution,
|
||||
variables: {
|
||||
id: 1,
|
||||
},
|
||||
@ -1213,19 +1213,19 @@ describe('AdminResolver', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('confirmPendingCreation', () => {
|
||||
describe('confirmContribution', () => {
|
||||
describe('creation does not exits', () => {
|
||||
it('throws an error', async () => {
|
||||
await expect(
|
||||
mutate({
|
||||
mutation: confirmPendingCreation,
|
||||
mutation: confirmContribution,
|
||||
variables: {
|
||||
id: -1,
|
||||
},
|
||||
}),
|
||||
).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
errors: [new GraphQLError('Creation not found to given id.')],
|
||||
errors: [new GraphQLError('Contribution not found to given id.')],
|
||||
}),
|
||||
)
|
||||
})
|
||||
@ -1245,14 +1245,14 @@ describe('AdminResolver', () => {
|
||||
it('thows an error', async () => {
|
||||
await expect(
|
||||
mutate({
|
||||
mutation: confirmPendingCreation,
|
||||
mutation: confirmContribution,
|
||||
variables: {
|
||||
id: creation ? creation.id : -1,
|
||||
},
|
||||
}),
|
||||
).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
errors: [new GraphQLError('Moderator can not confirm own pending creation')],
|
||||
errors: [new GraphQLError('Moderator can not confirm own contribution')],
|
||||
}),
|
||||
)
|
||||
})
|
||||
@ -1272,14 +1272,14 @@ describe('AdminResolver', () => {
|
||||
it('returns true', async () => {
|
||||
await expect(
|
||||
mutate({
|
||||
mutation: confirmPendingCreation,
|
||||
mutation: confirmContribution,
|
||||
variables: {
|
||||
id: creation ? creation.id : -1,
|
||||
},
|
||||
}),
|
||||
).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
data: { confirmPendingCreation: true },
|
||||
data: { confirmContribution: true },
|
||||
}),
|
||||
)
|
||||
})
|
||||
@ -1319,20 +1319,20 @@ describe('AdminResolver', () => {
|
||||
// In the futrue this should not throw anymore
|
||||
it('throws an error for the second confirmation', async () => {
|
||||
const r1 = mutate({
|
||||
mutation: confirmPendingCreation,
|
||||
mutation: confirmContribution,
|
||||
variables: {
|
||||
id: c1 ? c1.id : -1,
|
||||
},
|
||||
})
|
||||
const r2 = mutate({
|
||||
mutation: confirmPendingCreation,
|
||||
mutation: confirmContribution,
|
||||
variables: {
|
||||
id: c2 ? c2.id : -1,
|
||||
},
|
||||
})
|
||||
await expect(r1).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
data: { confirmPendingCreation: true },
|
||||
data: { confirmContribution: true },
|
||||
}),
|
||||
)
|
||||
await expect(r2).resolves.toEqual(
|
||||
|
||||
@ -325,22 +325,22 @@ export class AdminResolver {
|
||||
return !!res
|
||||
}
|
||||
|
||||
@Authorized([RIGHTS.CONFIRM_PENDING_CREATION])
|
||||
@Authorized([RIGHTS.CONFIRM_CONTRIBUTION])
|
||||
@Mutation(() => Boolean)
|
||||
async confirmPendingCreation(
|
||||
async confirmContribution(
|
||||
@Arg('id', () => Int) id: number,
|
||||
@Ctx() context: Context,
|
||||
): Promise<boolean> {
|
||||
const contribution = await Contribution.findOne(id)
|
||||
if (!contribution) {
|
||||
throw new Error('Creation not found to given id.')
|
||||
throw new Error('Contribution not found to given id.')
|
||||
}
|
||||
const moderatorUser = getUser(context)
|
||||
if (moderatorUser.id === contribution.userId)
|
||||
throw new Error('Moderator can not confirm own pending creation')
|
||||
throw new Error('Moderator can not confirm own contribution')
|
||||
|
||||
const user = await dbUser.findOneOrFail({ id: contribution.userId }, { withDeleted: true })
|
||||
if (user.deletedAt) throw new Error('This user was deleted. Cannot confirm a creation.')
|
||||
if (user.deletedAt) throw new Error('This user was deleted. Cannot confirm a contribution.')
|
||||
|
||||
const creations = await getUserCreation(contribution.userId, false)
|
||||
if (!isCreationValid(creations, contribution.amount, contribution.contributionDate)) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
|
||||
import { adminCreateContribution, confirmPendingCreation } from '@/seeds/graphql/mutations'
|
||||
import { adminCreateContribution, confirmContribution } from '@/seeds/graphql/mutations'
|
||||
import { login } from '@/seeds/graphql/queries'
|
||||
import { CreationInterface } from '@/seeds/creation/CreationInterface'
|
||||
import { ApolloServerTestClient } from 'apollo-server-testing'
|
||||
@ -33,7 +33,7 @@ export const creationFactory = async (
|
||||
})
|
||||
|
||||
if (creation.confirmed) {
|
||||
await mutate({ mutation: confirmPendingCreation, variables: { id: pendingCreation.id } })
|
||||
await mutate({ mutation: confirmContribution, variables: { id: pendingCreation.id } })
|
||||
|
||||
if (creation.moveCreationDate) {
|
||||
const transaction = await Transaction.findOneOrFail({
|
||||
|
||||
@ -92,9 +92,9 @@ export const adminCreateContribution = gql`
|
||||
}
|
||||
`
|
||||
|
||||
export const confirmPendingCreation = gql`
|
||||
export const confirmContribution = gql`
|
||||
mutation ($id: Int!) {
|
||||
confirmPendingCreation(id: $id)
|
||||
confirmContribution(id: $id)
|
||||
}
|
||||
`
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user