This commit is contained in:
Tom Moor 2018-08-06 22:22:15 -07:00
parent cad83f4e7b
commit 3334d783f3
2 changed files with 27 additions and 3 deletions

View File

@ -545,6 +545,20 @@ describe('#documents.create', async () => {
expect(body.data.text).toBe('# Untitled document');
});
it('should not allow very long titles', async () => {
const { user, collection } = await seed();
const res = await server.post('/api/documents.create', {
body: {
token: user.getJwtToken(),
collection: collection.id,
title:
'This is a really long title that is not acceptable to Outline because it is so ridiculously long that we need to have a limit somewhere',
text: ' ',
},
});
expect(res.status).toEqual(400);
});
it('should create as a child and add to collection if published', async () => {
const { user, document, collection } = await seed();
const res = await server.post('/api/documents.create', {

View File

@ -83,9 +83,19 @@ const Document = sequelize.define(
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
urlId: { type: DataTypes.STRING, primaryKey: true },
private: { type: DataTypes.BOOLEAN, defaultValue: true },
title: DataTypes.STRING,
urlId: {
type: DataTypes.STRING,
primaryKey: true,
},
title: {
type: DataTypes.STRING,
validate: {
len: {
args: [0, 100],
msg: 'Document title must be less than 100 characters',
},
},
},
text: DataTypes.TEXT,
revisionCount: { type: DataTypes.INTEGER, defaultValue: 0 },
publishedAt: DataTypes.DATE,