Skip to content

Commit

Permalink
🗜 Database soft limits
Browse files Browse the repository at this point in the history
closes TryGhost/Ghost#8143

- uses new soft limits in validation:
	- post title to 255
	- meta title to 300
	- meta description to 500
- updates test
  • Loading branch information
aileen committed May 2, 2017
1 parent d70ea17 commit 0ae85db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions app/validators/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ export default BaseValidator.create({
this.invalidate();
}

if (!validator.isLength(title, 0, 150)) {
model.get('errors').add('title', 'Title cannot be longer than 150 characters.');
if (!validator.isLength(title, 0, 255)) {
model.get('errors').add('title', 'Title cannot be longer than 255 characters.');
this.invalidate();
}
},

metaTitle(model) {
let metaTitle = model.get('metaTitle');

if (!validator.isLength(metaTitle, 0, 150)) {
model.get('errors').add('metaTitle', 'Meta Title cannot be longer than 150 characters.');
if (!validator.isLength(metaTitle, 0, 300)) {
model.get('errors').add('metaTitle', 'Meta Title cannot be longer than 300 characters.');
this.invalidate();
}
},

metaDescription(model) {
let metaDescription = model.get('metaDescription');

if (!validator.isLength(metaDescription, 0, 200)) {
model.get('errors').add('metaDescription', 'Meta Description cannot be longer than 200 characters.');
if (!validator.isLength(metaDescription, 0, 500)) {
model.get('errors').add('metaDescription', 'Meta Description cannot be longer than 500 characters.');
this.invalidate();
}
},
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/editor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ describe('Acceptance: Editor', function() {
titleRendered();

let title = find('#gh-editor-title div');
title.html(Array(160).join('a'));
title.html(Array(260).join('a'));

await click(testSelector('publishmenu-trigger'));
await click(testSelector('publishmenu-save'));
Expand All @@ -342,7 +342,7 @@ describe('Acceptance: Editor', function() {
expect(
find('.gh-alert').text(),
'alert text after invalid title'
).to.match(/Title cannot be longer than 150 characters/);
).to.match(/Title cannot be longer than 255 characters/);
});

it('inserts a placeholder if the title is blank', async function () {
Expand Down

0 comments on commit 0ae85db

Please sign in to comment.