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',
|
type: 'string',
|
||||||
allow: [null],
|
allow: [null],
|
||||||
},
|
},
|
||||||
/* termsAndConditionsAgreedAt: {
|
termsAndConditionsAgreedAt: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
isoDate: true,
|
isoDate: true,
|
||||||
allow: [null],
|
allow: [null],
|
||||||
// required: true, TODO
|
},
|
||||||
}, */
|
|
||||||
shouted: {
|
shouted: {
|
||||||
type: 'relationship',
|
type: 'relationship',
|
||||||
relationship: 'SHOUTED',
|
relationship: 'SHOUTED',
|
||||||
|
|||||||
@ -82,6 +82,7 @@ export default {
|
|||||||
if (!regEx.test(termsAndConditionsAgreedVersion)) {
|
if (!regEx.test(termsAndConditionsAgreedVersion)) {
|
||||||
throw new UserInputError('Invalid version format!')
|
throw new UserInputError('Invalid version format!')
|
||||||
}
|
}
|
||||||
|
args.termsAndConditionsAgreedAt = new Date().toISOString()
|
||||||
|
|
||||||
let { nonce, email } = args
|
let { nonce, email } = args
|
||||||
email = email.toLowerCase()
|
email = email.toLowerCase()
|
||||||
|
|||||||
@ -62,7 +62,7 @@ describe('CreateInvitationCode', () => {
|
|||||||
name: 'Inviter',
|
name: 'Inviter',
|
||||||
email: 'inviter@example.org',
|
email: 'inviter@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
termsAndConditionsAgreedVersion: '0.0.1',
|
termsAndConditionsAgreedVersion: null,
|
||||||
})
|
})
|
||||||
authenticatedUser = await user.toJson()
|
authenticatedUser = await user.toJson()
|
||||||
})
|
})
|
||||||
@ -340,6 +340,7 @@ describe('SignupVerification', () => {
|
|||||||
) {
|
) {
|
||||||
id
|
id
|
||||||
termsAndConditionsAgreedVersion
|
termsAndConditionsAgreedVersion
|
||||||
|
termsAndConditionsAgreedAt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
@ -351,7 +352,7 @@ describe('SignupVerification', () => {
|
|||||||
name: 'John Doe',
|
name: 'John Doe',
|
||||||
password: '123',
|
password: '123',
|
||||||
email: 'john@example.org',
|
email: 'john@example.org',
|
||||||
termsAndConditionsAgreedVersion: '0.0.1',
|
termsAndConditionsAgreedVersion: '0.1.0',
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -444,16 +445,38 @@ describe('SignupVerification', () => {
|
|||||||
expect(emails).toHaveLength(1)
|
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({
|
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
SignupVerification: expect.objectContaining({
|
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 () => {
|
it('rejects if version of terms and conditions has wrong format', async () => {
|
||||||
variables = { ...variables, termsAndConditionsAgreedVersion: 'invalid version format' }
|
variables = { ...variables, termsAndConditionsAgreedVersion: 'invalid version format' }
|
||||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
||||||
|
|||||||
@ -94,6 +94,7 @@ export default {
|
|||||||
if (!regEx.test(termsAndConditionsAgreedVersion)) {
|
if (!regEx.test(termsAndConditionsAgreedVersion)) {
|
||||||
throw new ForbiddenError('Invalid version format!')
|
throw new ForbiddenError('Invalid version format!')
|
||||||
}
|
}
|
||||||
|
args.termsAndConditionsAgreedAt = new Date().toISOString()
|
||||||
}
|
}
|
||||||
args = await fileUpload(args, { file: 'avatarUpload', url: 'avatar' })
|
args = await fileUpload(args, { file: 'avatarUpload', url: 'avatar' })
|
||||||
try {
|
try {
|
||||||
@ -165,7 +166,6 @@ export default {
|
|||||||
},
|
},
|
||||||
...Resolver('User', {
|
...Resolver('User', {
|
||||||
undefinedToNull: [
|
undefinedToNull: [
|
||||||
'termsAndConditionsAgreedVersion',
|
|
||||||
'actorId',
|
'actorId',
|
||||||
'avatar',
|
'avatar',
|
||||||
'coverImg',
|
'coverImg',
|
||||||
@ -174,7 +174,7 @@ export default {
|
|||||||
'locationName',
|
'locationName',
|
||||||
'about',
|
'about',
|
||||||
'termsAndConditionsAgreedVersion',
|
'termsAndConditionsAgreedVersion',
|
||||||
// TODO: 'termsAndConditionsAgreedAt',
|
'termsAndConditionsAgreedAt',
|
||||||
],
|
],
|
||||||
boolean: {
|
boolean: {
|
||||||
followedByCurrentUser:
|
followedByCurrentUser:
|
||||||
|
|||||||
@ -84,6 +84,8 @@ describe('UpdateUser', () => {
|
|||||||
password: '1234',
|
password: '1234',
|
||||||
id: 'u47',
|
id: 'u47',
|
||||||
name: 'John Doe',
|
name: 'John Doe',
|
||||||
|
termsAndConditionsAgreedVersion: null,
|
||||||
|
termsAndConditionsAgreedAt: null,
|
||||||
}
|
}
|
||||||
|
|
||||||
variables = {
|
variables = {
|
||||||
@ -102,6 +104,7 @@ describe('UpdateUser', () => {
|
|||||||
id
|
id
|
||||||
name
|
name
|
||||||
termsAndConditionsAgreedVersion
|
termsAndConditionsAgreedVersion
|
||||||
|
termsAndConditionsAgreedAt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
@ -171,19 +174,44 @@ describe('UpdateUser', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('given a new agreed version of terms and conditions', async () => {
|
describe('given a new agreed version of terms and conditions', () => {
|
||||||
variables = { ...variables, termsAndConditionsAgreedVersion: '0.0.2' }
|
beforeEach(async () => {
|
||||||
const expected = {
|
variables = { ...variables, termsAndConditionsAgreedVersion: '0.0.2' }
|
||||||
data: {
|
})
|
||||||
UpdateUser: expect.objectContaining({
|
it('update termsAndConditionsAgreedVersion', async () => {
|
||||||
termsAndConditionsAgreedVersion: '0.0.2',
|
const expected = {
|
||||||
}),
|
data: {
|
||||||
},
|
UpdateUser: expect.objectContaining({
|
||||||
}
|
termsAndConditionsAgreedVersion: '0.0.2',
|
||||||
|
termsAndConditionsAgreedAt: expect.any(String),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
await expect(mutate({ mutation: updateUserMutation, variables })).resolves.toMatchObject(
|
await expect(mutate({ mutation: updateUserMutation, variables })).resolves.toMatchObject(
|
||||||
expected,
|
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 () => {
|
it('rejects if version of terms and conditions has wrong format', async () => {
|
||||||
|
|||||||
@ -18,6 +18,6 @@ type Mutation {
|
|||||||
avatarUpload: Upload
|
avatarUpload: Upload
|
||||||
locationName: String
|
locationName: String
|
||||||
about: String
|
about: String
|
||||||
termsAndConditionsAgreedVersion: String
|
termsAndConditionsAgreedVersion: String!
|
||||||
): User
|
): User
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,7 @@ type User {
|
|||||||
updatedAt: String
|
updatedAt: String
|
||||||
|
|
||||||
termsAndConditionsAgreedVersion: String
|
termsAndConditionsAgreedVersion: String
|
||||||
|
termsAndConditionsAgreedAt: String
|
||||||
|
|
||||||
friends: [User]! @relation(name: "FRIENDS", direction: "BOTH")
|
friends: [User]! @relation(name: "FRIENDS", direction: "BOTH")
|
||||||
friendsCount: Int! @cypher(statement: "MATCH (this)<-[: FRIENDS]->(r: User) RETURN COUNT(DISTINCT r)")
|
friendsCount: Int! @cypher(statement: "MATCH (this)<-[: FRIENDS]->(r: User) RETURN COUNT(DISTINCT r)")
|
||||||
@ -164,6 +165,7 @@ type Mutation {
|
|||||||
locationName: String
|
locationName: String
|
||||||
about: String
|
about: String
|
||||||
termsAndConditionsAgreedVersion: String
|
termsAndConditionsAgreedVersion: String
|
||||||
|
termsAndConditionsAgreedAt: String
|
||||||
): User
|
): User
|
||||||
|
|
||||||
DeleteUser(id: ID!, resource: [Deletable]): User
|
DeleteUser(id: ID!, resource: [Deletable]): User
|
||||||
|
|||||||
@ -14,8 +14,8 @@ export default function create() {
|
|||||||
role: 'user',
|
role: 'user',
|
||||||
avatar: faker.internet.avatar(),
|
avatar: faker.internet.avatar(),
|
||||||
about: faker.lorem.paragraph(),
|
about: faker.lorem.paragraph(),
|
||||||
// termsAndConditionsAgreedAt: new Date().toISOString(),
|
|
||||||
termsAndConditionsAgreedVersion: '0.0.1',
|
termsAndConditionsAgreedVersion: '0.0.1',
|
||||||
|
termsAndConditionsAgreedAt: '2019-08-01T10:47:19.212Z',
|
||||||
}
|
}
|
||||||
defaults.slug = slugify(defaults.name, { lower: true })
|
defaults.slug = slugify(defaults.name, { lower: true })
|
||||||
args = {
|
args = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user