mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Merge pull request #1556 from Human-Connection/1503_datum_agb
II Add Date to Terms and Conditions #1535
This commit is contained in:
commit
193ac8e6b2
@ -87,12 +87,11 @@ module.exports = {
|
||||
type: 'string',
|
||||
allow: [null],
|
||||
},
|
||||
/* termsAndConditionsAgreedAt: {
|
||||
termsAndConditionsAgreedAt: {
|
||||
type: 'string',
|
||||
isoDate: true,
|
||||
allow: [null],
|
||||
// required: true, TODO
|
||||
}, */
|
||||
},
|
||||
shouted: {
|
||||
type: 'relationship',
|
||||
relationship: 'SHOUTED',
|
||||
|
||||
@ -82,6 +82,7 @@ export default {
|
||||
if (!regEx.test(termsAndConditionsAgreedVersion)) {
|
||||
throw new UserInputError('Invalid version format!')
|
||||
}
|
||||
args.termsAndConditionsAgreedAt = new Date().toISOString()
|
||||
|
||||
let { nonce, email } = args
|
||||
email = email.toLowerCase()
|
||||
|
||||
@ -62,7 +62,7 @@ describe('CreateInvitationCode', () => {
|
||||
name: 'Inviter',
|
||||
email: 'inviter@example.org',
|
||||
password: '1234',
|
||||
termsAndConditionsAgreedVersion: '0.0.1',
|
||||
termsAndConditionsAgreedVersion: null,
|
||||
})
|
||||
authenticatedUser = await user.toJson()
|
||||
})
|
||||
@ -340,6 +340,7 @@ describe('SignupVerification', () => {
|
||||
) {
|
||||
id
|
||||
termsAndConditionsAgreedVersion
|
||||
termsAndConditionsAgreedAt
|
||||
}
|
||||
}
|
||||
`
|
||||
@ -351,7 +352,7 @@ describe('SignupVerification', () => {
|
||||
name: 'John Doe',
|
||||
password: '123',
|
||||
email: 'john@example.org',
|
||||
termsAndConditionsAgreedVersion: '0.0.1',
|
||||
termsAndConditionsAgreedVersion: '0.1.0',
|
||||
}
|
||||
})
|
||||
|
||||
@ -444,16 +445,38 @@ describe('SignupVerification', () => {
|
||||
expect(emails).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('is version of terms and conditions saved correctly', async () => {
|
||||
it('updates termsAndConditionsAgreedVersion', async () => {
|
||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
||||
data: {
|
||||
SignupVerification: expect.objectContaining({
|
||||
termsAndConditionsAgreedVersion: '0.0.1',
|
||||
termsAndConditionsAgreedVersion: '0.1.0',
|
||||
}),
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('updates termsAndConditionsAgreedAt', async () => {
|
||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
||||
data: {
|
||||
SignupVerification: expect.objectContaining({
|
||||
termsAndConditionsAgreedAt: expect.any(String),
|
||||
}),
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('rejects if version of terms and conditions is missing', async () => {
|
||||
variables = { ...variables, termsAndConditionsAgreedVersion: null }
|
||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
||||
errors: [
|
||||
{
|
||||
message:
|
||||
'Variable "$termsAndConditionsAgreedVersion" of non-null type "String!" must not be null.',
|
||||
},
|
||||
],
|
||||
})
|
||||
})
|
||||
|
||||
it('rejects if version of terms and conditions has wrong format', async () => {
|
||||
variables = { ...variables, termsAndConditionsAgreedVersion: 'invalid version format' }
|
||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
||||
|
||||
@ -94,6 +94,7 @@ export default {
|
||||
if (!regEx.test(termsAndConditionsAgreedVersion)) {
|
||||
throw new ForbiddenError('Invalid version format!')
|
||||
}
|
||||
args.termsAndConditionsAgreedAt = new Date().toISOString()
|
||||
}
|
||||
args = await fileUpload(args, { file: 'avatarUpload', url: 'avatar' })
|
||||
try {
|
||||
@ -165,7 +166,6 @@ export default {
|
||||
},
|
||||
...Resolver('User', {
|
||||
undefinedToNull: [
|
||||
'termsAndConditionsAgreedVersion',
|
||||
'actorId',
|
||||
'avatar',
|
||||
'coverImg',
|
||||
@ -174,7 +174,7 @@ export default {
|
||||
'locationName',
|
||||
'about',
|
||||
'termsAndConditionsAgreedVersion',
|
||||
// TODO: 'termsAndConditionsAgreedAt',
|
||||
'termsAndConditionsAgreedAt',
|
||||
],
|
||||
boolean: {
|
||||
followedByCurrentUser:
|
||||
|
||||
@ -84,6 +84,8 @@ describe('UpdateUser', () => {
|
||||
password: '1234',
|
||||
id: 'u47',
|
||||
name: 'John Doe',
|
||||
termsAndConditionsAgreedVersion: null,
|
||||
termsAndConditionsAgreedAt: null,
|
||||
}
|
||||
|
||||
variables = {
|
||||
@ -102,6 +104,7 @@ describe('UpdateUser', () => {
|
||||
id
|
||||
name
|
||||
termsAndConditionsAgreedVersion
|
||||
termsAndConditionsAgreedAt
|
||||
}
|
||||
}
|
||||
`
|
||||
@ -171,19 +174,44 @@ describe('UpdateUser', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('given a new agreed version of terms and conditions', async () => {
|
||||
variables = { ...variables, termsAndConditionsAgreedVersion: '0.0.2' }
|
||||
const expected = {
|
||||
data: {
|
||||
UpdateUser: expect.objectContaining({
|
||||
termsAndConditionsAgreedVersion: '0.0.2',
|
||||
}),
|
||||
},
|
||||
}
|
||||
describe('given a new agreed version of terms and conditions', () => {
|
||||
beforeEach(async () => {
|
||||
variables = { ...variables, termsAndConditionsAgreedVersion: '0.0.2' }
|
||||
})
|
||||
it('update termsAndConditionsAgreedVersion', async () => {
|
||||
const expected = {
|
||||
data: {
|
||||
UpdateUser: expect.objectContaining({
|
||||
termsAndConditionsAgreedVersion: '0.0.2',
|
||||
termsAndConditionsAgreedAt: expect.any(String),
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
||||
await expect(mutate({ mutation: updateUserMutation, variables })).resolves.toMatchObject(
|
||||
expected,
|
||||
)
|
||||
await expect(mutate({ mutation: updateUserMutation, variables })).resolves.toMatchObject(
|
||||
expected,
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('given any attribute other than termsAndConditionsAgreedVersion', () => {
|
||||
beforeEach(async () => {
|
||||
variables = { ...variables, name: 'any name' }
|
||||
})
|
||||
it('update termsAndConditionsAgreedVersion', async () => {
|
||||
const expected = {
|
||||
data: {
|
||||
UpdateUser: expect.objectContaining({
|
||||
termsAndConditionsAgreedVersion: null,
|
||||
termsAndConditionsAgreedAt: null,
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
||||
await expect(mutate({ mutation: updateUserMutation, variables })).resolves.toMatchObject(
|
||||
expected,
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it('rejects if version of terms and conditions has wrong format', async () => {
|
||||
|
||||
@ -18,6 +18,6 @@ type Mutation {
|
||||
avatarUpload: Upload
|
||||
locationName: String
|
||||
about: String
|
||||
termsAndConditionsAgreedVersion: String
|
||||
termsAndConditionsAgreedVersion: String!
|
||||
): User
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@ type User {
|
||||
updatedAt: String
|
||||
|
||||
termsAndConditionsAgreedVersion: String
|
||||
termsAndConditionsAgreedAt: String
|
||||
|
||||
friends: [User]! @relation(name: "FRIENDS", direction: "BOTH")
|
||||
friendsCount: Int! @cypher(statement: "MATCH (this)<-[: FRIENDS]->(r: User) RETURN COUNT(DISTINCT r)")
|
||||
@ -164,6 +165,7 @@ type Mutation {
|
||||
locationName: String
|
||||
about: String
|
||||
termsAndConditionsAgreedVersion: String
|
||||
termsAndConditionsAgreedAt: String
|
||||
): User
|
||||
|
||||
DeleteUser(id: ID!, resource: [Deletable]): User
|
||||
|
||||
@ -14,8 +14,8 @@ export default function create() {
|
||||
role: 'user',
|
||||
avatar: faker.internet.avatar(),
|
||||
about: faker.lorem.paragraph(),
|
||||
// termsAndConditionsAgreedAt: new Date().toISOString(),
|
||||
termsAndConditionsAgreedVersion: '0.0.1',
|
||||
termsAndConditionsAgreedAt: '2019-08-01T10:47:19.212Z',
|
||||
}
|
||||
defaults.slug = slugify(defaults.name, { lower: true })
|
||||
args = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user