mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Delete emails and social media, bugfix
The bugfix was missing '(' plus a wrong order for the social media
relationship called 'OWNED_BY'.
This commit is contained in:
parent
8c7e3708a4
commit
bd885b1aac
@ -8,7 +8,7 @@ module.exports = {
|
||||
type: 'relationship',
|
||||
relationship: 'OWNED_BY',
|
||||
target: 'User',
|
||||
direction: 'in',
|
||||
direction: 'out',
|
||||
eager: true,
|
||||
cascade: 'detach',
|
||||
},
|
||||
|
||||
@ -32,7 +32,7 @@ export default {
|
||||
SocialMedia: Resolver('SocialMedia', {
|
||||
idAttribute: 'url',
|
||||
hasOne: {
|
||||
ownedBy: '<-[:OWNED_BY]-(related:User)',
|
||||
ownedBy: '-[:OWNED_BY]->(related:User)',
|
||||
},
|
||||
}),
|
||||
}
|
||||
|
||||
@ -129,6 +129,12 @@ export default {
|
||||
SET user.deleted = true
|
||||
SET user.name = 'UNAVAILABLE'
|
||||
SET user.about = 'UNAVAILABLE'
|
||||
WITH user
|
||||
OPTIONAL MATCH (user)<-[:BELONGS_TO]-(email:EmailAddress)
|
||||
DETACH DELETE email
|
||||
WITH user
|
||||
OPTIONAL MATCH (user)<-[:OWNED_BY]-(socialMedia:SocialMedia)
|
||||
DETACH DELETE socialMedia
|
||||
RETURN user`,
|
||||
{ userId: context.user.id },
|
||||
)
|
||||
@ -185,7 +191,7 @@ export default {
|
||||
followedBy: '<-[:FOLLOWS]-(related:User)',
|
||||
following: '-[:FOLLOWS]->(related:User)',
|
||||
friends: '-[:FRIENDS]-(related:User)',
|
||||
socialMedia: '-[:OWNED_BY]->(related:SocialMedia',
|
||||
socialMedia: '<-[:OWNED_BY]-(related:SocialMedia)',
|
||||
contributions: '-[:WROTE]->(related:Post)',
|
||||
comments: '-[:WROTE]->(related:Comment)',
|
||||
shouted: '-[:SHOUTED]->(related:Post)',
|
||||
|
||||
@ -50,8 +50,9 @@ describe('User', () => {
|
||||
const variables = { email: 'any-email-address@example.org' }
|
||||
|
||||
it('is forbidden', async () => {
|
||||
const { errors } = await query({ query: userQuery, variables })
|
||||
expect(errors[0]).toHaveProperty('message', 'Not Authorised!')
|
||||
await expect(query({ query: userQuery, variables })).resolves.toMatchObject({
|
||||
errors: [{ message: 'Not Authorised!' }],
|
||||
})
|
||||
})
|
||||
|
||||
describe('as admin', () => {
|
||||
@ -439,6 +440,27 @@ describe('DeleteUser', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('connected `EmailAddress` nodes', () => {
|
||||
it('will be removed completely', async () => {
|
||||
await expect(neode.all('EmailAddress')).resolves.toHaveLength(2)
|
||||
await mutate({ mutation: deleteUserMutation, variables })
|
||||
await expect(neode.all('EmailAddress')).resolves.toHaveLength(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('connected `SocialMedia` nodes', () => {
|
||||
beforeEach(async () => {
|
||||
const socialMedia = await factory.create('SocialMedia')
|
||||
await socialMedia.relateTo(user, 'ownedBy')
|
||||
})
|
||||
|
||||
it('will be removed completely', async () => {
|
||||
await expect(neode.all('SocialMedia')).resolves.toHaveLength(1)
|
||||
await mutate({ mutation: deleteUserMutation, variables })
|
||||
await expect(neode.all('SocialMedia')).resolves.toHaveLength(0)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -17,7 +17,7 @@ type User {
|
||||
location: Location @cypher(statement: "MATCH (this)-[:IS_IN]->(l:Location) RETURN l")
|
||||
locationName: String
|
||||
about: String
|
||||
socialMedia: [SocialMedia]! @relation(name: "OWNED_BY", direction: "OUT")
|
||||
socialMedia: [SocialMedia]! @relation(name: "OWNED_BY", direction: "IN")
|
||||
|
||||
#createdAt: DateTime
|
||||
#updatedAt: DateTime
|
||||
|
||||
@ -6,6 +6,7 @@ import createPost from './posts.js'
|
||||
import createComment from './comments.js'
|
||||
import createCategory from './categories.js'
|
||||
import createTag from './tags.js'
|
||||
import createSocialMedia from './socialMedia.js'
|
||||
|
||||
export const seedServerHost = 'http://127.0.0.1:4001'
|
||||
|
||||
@ -26,6 +27,7 @@ const factories = {
|
||||
Comment: createComment,
|
||||
Category: createCategory,
|
||||
Tag: createTag,
|
||||
SocialMedia: createSocialMedia,
|
||||
}
|
||||
|
||||
export const cleanDatabase = async (options = {}) => {
|
||||
|
||||
14
backend/src/seed/factories/socialMedia.js
Normal file
14
backend/src/seed/factories/socialMedia.js
Normal file
@ -0,0 +1,14 @@
|
||||
export default function create() {
|
||||
return {
|
||||
factory: async ({ args, neodeInstance }) => {
|
||||
const defaults = {
|
||||
url: 'https://mastodon.social/@Gargron',
|
||||
}
|
||||
args = {
|
||||
...defaults,
|
||||
...args,
|
||||
}
|
||||
return neodeInstance.create('SocialMedia', args)
|
||||
},
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user