mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Prevent to report any type
Resouce must have a label (Post|Comment|User)
This commit is contained in:
parent
ee5c4127e6
commit
60d711bb0a
@ -17,7 +17,7 @@ export default {
|
||||
const [resource] = res.records.map((record) => {
|
||||
return record.get('resource')
|
||||
})
|
||||
if(!resource) return null
|
||||
if (!resource) return null
|
||||
return resource.id
|
||||
},
|
||||
enable: async (object, params, { user, driver }) => {
|
||||
@ -34,7 +34,7 @@ export default {
|
||||
const [resource] = res.records.map((record) => {
|
||||
return record.get('resource')
|
||||
})
|
||||
if(!resource) return null
|
||||
if (!resource) return null
|
||||
return resource.id
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,7 +14,6 @@ const setupAuthenticateClient = (params) => {
|
||||
return authenticateClient
|
||||
}
|
||||
|
||||
|
||||
let createResource
|
||||
let authenticateClient
|
||||
beforeEach(() => {
|
||||
@ -87,7 +86,7 @@ describe('disable', () => {
|
||||
}
|
||||
createResource = () => {
|
||||
return Promise.all([
|
||||
factory.create('Tag', { id: 't23' }),
|
||||
factory.create('Tag', { id: 't23' })
|
||||
])
|
||||
}
|
||||
})
|
||||
@ -261,7 +260,7 @@ describe('enable', () => {
|
||||
createResource = () => {
|
||||
// we cannot create a :DISABLED relationship here
|
||||
return Promise.all([
|
||||
factory.create('Tag', { id: 't23' }),
|
||||
factory.create('Tag', { id: 't23' })
|
||||
])
|
||||
}
|
||||
})
|
||||
|
||||
@ -14,6 +14,7 @@ export default {
|
||||
const res = await session.run(`
|
||||
MATCH (submitter:User {id: $userId})
|
||||
MATCH (resource {id: $resourceId})
|
||||
WHERE resource:User OR resource:Comment OR resource:Post
|
||||
CREATE (report:Report $reportData)
|
||||
MERGE (resource)<-[:REPORTED]-(report)
|
||||
MERGE (report)<-[:REPORTED]-(submitter)
|
||||
|
||||
@ -11,6 +11,8 @@ describe('report', () => {
|
||||
let variables
|
||||
|
||||
beforeEach(async () => {
|
||||
returnedObject = '{ description }'
|
||||
variables = { id: 'whatever' }
|
||||
headers = {}
|
||||
await factory.create('User', {
|
||||
id: 'u1',
|
||||
@ -36,10 +38,9 @@ describe('report', () => {
|
||||
report(
|
||||
id: $id,
|
||||
description: "Violates code of conduct"
|
||||
) ${returnedObject || '{ description }'}
|
||||
) ${returnedObject}
|
||||
}
|
||||
`
|
||||
variables = variables || { id: 'whatever' }
|
||||
client = new GraphQLClient(host, { headers })
|
||||
return client.request(mutation, variables)
|
||||
}
|
||||
@ -146,6 +147,17 @@ describe('report', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('reported resource is a tag', () => {
|
||||
beforeEach(async () => {
|
||||
await factory.create('Tag', { id: 't23' })
|
||||
variables = { id: 't23' }
|
||||
})
|
||||
|
||||
it('returns null', async () => {
|
||||
await expect(action()).resolves.toEqual({ report: null })
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user