mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-27 10:42:45 +03:00
Standardise client property names to camelCase
closes #6018 - added keyForAttribute method in application serializer - override keyForAttribute in settings serializer to not apply camelCase/underscore conversion - rename under_scored properties to camelCased
This commit is contained in:
parent
15144dd551
commit
c4371a36f2
@ -18,8 +18,8 @@ export default Component.extend({
|
|||||||
scratchName: boundOneWay('tag.name'),
|
scratchName: boundOneWay('tag.name'),
|
||||||
scratchSlug: boundOneWay('tag.slug'),
|
scratchSlug: boundOneWay('tag.slug'),
|
||||||
scratchDescription: boundOneWay('tag.description'),
|
scratchDescription: boundOneWay('tag.description'),
|
||||||
scratchMetaTitle: boundOneWay('tag.meta_title'),
|
scratchMetaTitle: boundOneWay('tag.metaTitle'),
|
||||||
scratchMetaDescription: boundOneWay('tag.meta_description'),
|
scratchMetaDescription: boundOneWay('tag.metaDescription'),
|
||||||
|
|
||||||
isViewingSubview: false,
|
isViewingSubview: false,
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@ export default Component.extend({
|
|||||||
return Ember.String.htmlSafe(`background-image: url(${url})`);
|
return Ember.String.htmlSafe(`background-image: url(${url})`);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
lastLogin: computed('user.last_login', function () {
|
lastLogin: computed('user.lastLogin', function () {
|
||||||
let lastLogin = this.get('user.last_login');
|
let lastLogin = this.get('user.lastLogin');
|
||||||
|
|
||||||
return lastLogin ? lastLogin.fromNow() : '(Never)';
|
return lastLogin ? lastLogin.fromNow() : '(Never)';
|
||||||
})
|
})
|
||||||
|
@ -14,8 +14,8 @@ export default Component.extend({
|
|||||||
|
|
||||||
notifications: service(),
|
notifications: service(),
|
||||||
|
|
||||||
createdAt: computed('user.created_at', function () {
|
createdAt: computed('user.createdAt', function () {
|
||||||
let createdAt = this.get('user.created_at');
|
let createdAt = this.get('user.createdAt');
|
||||||
|
|
||||||
return createdAt ? createdAt.fromNow() : '';
|
return createdAt ? createdAt.fromNow() : '';
|
||||||
}),
|
}),
|
||||||
|
@ -85,8 +85,8 @@ export default Controller.extend(SettingsMenuMixin, {
|
|||||||
this.set('lastPromise', promise);
|
this.set('lastPromise', promise);
|
||||||
},
|
},
|
||||||
|
|
||||||
metaTitleScratch: boundOneWay('model.meta_title'),
|
metaTitleScratch: boundOneWay('model.metaTitle'),
|
||||||
metaDescriptionScratch: boundOneWay('model.meta_description'),
|
metaDescriptionScratch: boundOneWay('model.metaDescription'),
|
||||||
|
|
||||||
seoTitle: computed('model.titleScratch', 'metaTitleScratch', function () {
|
seoTitle: computed('model.titleScratch', 'metaTitleScratch', function () {
|
||||||
let metaTitle = this.get('metaTitleScratch') || '';
|
let metaTitle = this.get('metaTitleScratch') || '';
|
||||||
@ -291,13 +291,13 @@ export default Controller.extend(SettingsMenuMixin, {
|
|||||||
*/
|
*/
|
||||||
setPublishedAt(userInput) {
|
setPublishedAt(userInput) {
|
||||||
let newPublishedAt = parseDateString(userInput);
|
let newPublishedAt = parseDateString(userInput);
|
||||||
let publishedAt = moment(this.get('model.published_at'));
|
let publishedAt = moment(this.get('model.publishedAt'));
|
||||||
let errMessage = '';
|
let errMessage = '';
|
||||||
|
|
||||||
if (!userInput) {
|
if (!userInput) {
|
||||||
// Clear out the published_at field for a draft
|
// Clear out the publishedAt field for a draft
|
||||||
if (this.get('model.isDraft')) {
|
if (this.get('model.isDraft')) {
|
||||||
this.set('model.published_at', null);
|
this.set('model.publishedAt', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -324,7 +324,7 @@ export default Controller.extend(SettingsMenuMixin, {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validation complete
|
// Validation complete
|
||||||
this.set('model.published_at', newPublishedAt);
|
this.set('model.publishedAt', newPublishedAt);
|
||||||
|
|
||||||
// If this is a new post. Don't save the model. Defer the save
|
// If this is a new post. Don't save the model. Defer the save
|
||||||
// to the user pressing the save button
|
// to the user pressing the save button
|
||||||
@ -339,7 +339,7 @@ export default Controller.extend(SettingsMenuMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setMetaTitle(metaTitle) {
|
setMetaTitle(metaTitle) {
|
||||||
let property = 'meta_title';
|
let property = 'metaTitle';
|
||||||
let model = this.get('model');
|
let model = this.get('model');
|
||||||
let currentTitle = model.get(property) || '';
|
let currentTitle = model.get(property) || '';
|
||||||
|
|
||||||
@ -360,7 +360,7 @@ export default Controller.extend(SettingsMenuMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setMetaDescription(metaDescription) {
|
setMetaDescription(metaDescription) {
|
||||||
let property = 'meta_description';
|
let property = 'metaDescription';
|
||||||
let model = this.get('model');
|
let model = this.get('model');
|
||||||
let currentDescription = model.get(property) || '';
|
let currentDescription = model.get(property) || '';
|
||||||
|
|
||||||
|
@ -5,18 +5,18 @@ const {equal} = computed;
|
|||||||
|
|
||||||
// a custom sort function is needed in order to sort the posts list the same way the server would:
|
// a custom sort function is needed in order to sort the posts list the same way the server would:
|
||||||
// status: ASC
|
// status: ASC
|
||||||
// published_at: DESC
|
// publishedAt: DESC
|
||||||
// updated_at: DESC
|
// updatedAt: DESC
|
||||||
// id: DESC
|
// id: DESC
|
||||||
function comparator(item1, item2) {
|
function comparator(item1, item2) {
|
||||||
let updated1 = item1.get('updated_at');
|
let updated1 = item1.get('updatedAt');
|
||||||
let updated2 = item2.get('updated_at');
|
let updated2 = item2.get('updatedAt');
|
||||||
let idResult,
|
let idResult,
|
||||||
publishedAtResult,
|
publishedAtResult,
|
||||||
statusResult,
|
statusResult,
|
||||||
updatedAtResult;
|
updatedAtResult;
|
||||||
|
|
||||||
// when `updated_at` is undefined, the model is still
|
// when `updatedAt` is undefined, the model is still
|
||||||
// being written to with the results from the server
|
// being written to with the results from the server
|
||||||
if (item1.get('isNew') || !updated1) {
|
if (item1.get('isNew') || !updated1) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -48,8 +48,8 @@ function comparator(item1, item2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function publishedAtCompare(item1, item2) {
|
function publishedAtCompare(item1, item2) {
|
||||||
let published1 = item1.get('published_at');
|
let published1 = item1.get('publishedAt');
|
||||||
let published2 = item2.get('published_at');
|
let published2 = item2.get('publishedAt');
|
||||||
|
|
||||||
if (!published1 && !published2) {
|
if (!published1 && !published2) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -74,7 +74,7 @@ export default Controller.extend({
|
|||||||
postListFocused: equal('keyboardFocus', 'postList'),
|
postListFocused: equal('keyboardFocus', 'postList'),
|
||||||
postContentFocused: equal('keyboardFocus', 'postContent'),
|
postContentFocused: equal('keyboardFocus', 'postContent'),
|
||||||
|
|
||||||
sortedPosts: computed('model.@each.status', 'model.@each.published_at', 'model.@each.isNew', 'model.@each.updated_at', function () {
|
sortedPosts: computed('model.@each.status', 'model.@each.publishedAt', 'model.@each.isNew', 'model.@each.updatedAt', function () {
|
||||||
let postsArray = this.get('model').toArray();
|
let postsArray = this.get('model').toArray();
|
||||||
|
|
||||||
return postsArray.sort(comparator);
|
return postsArray.sort(comparator);
|
||||||
|
@ -308,8 +308,8 @@ export default Mixin.create({
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.set('model.title', this.get('model.titleScratch'));
|
this.set('model.title', this.get('model.titleScratch'));
|
||||||
this.set('model.meta_title', psmController.get('metaTitleScratch'));
|
this.set('model.metaTitle', psmController.get('metaTitleScratch'));
|
||||||
this.set('model.meta_description', psmController.get('metaDescriptionScratch'));
|
this.set('model.metaDescription', psmController.get('metaDescriptionScratch'));
|
||||||
|
|
||||||
if (!this.get('model.slug')) {
|
if (!this.get('model.slug')) {
|
||||||
// Cancel any pending slug generation that may still be queued in the
|
// Cancel any pending slug generation that may still be queued in the
|
||||||
|
@ -24,16 +24,16 @@ export default Model.extend(ValidationEngine, {
|
|||||||
page: attr('boolean', {defaultValue: false}),
|
page: attr('boolean', {defaultValue: false}),
|
||||||
status: attr('string', {defaultValue: 'draft'}),
|
status: attr('string', {defaultValue: 'draft'}),
|
||||||
language: attr('string', {defaultValue: 'en_US'}),
|
language: attr('string', {defaultValue: 'en_US'}),
|
||||||
meta_title: attr('string'),
|
metaTitle: attr('string'),
|
||||||
meta_description: attr('string'),
|
metaDescription: attr('string'),
|
||||||
author: belongsTo('user', {async: true}),
|
author: belongsTo('user', {async: true}),
|
||||||
author_id: attr('number'),
|
authorId: attr('number'),
|
||||||
updated_at: attr('moment-date'),
|
updatedAt: attr('moment-date'),
|
||||||
updated_by: attr(),
|
updatedBy: attr(),
|
||||||
published_at: attr('moment-date'),
|
publishedAt: attr('moment-date'),
|
||||||
published_by: belongsTo('user', {async: true}),
|
publishedBy: belongsTo('user', {async: true}),
|
||||||
created_at: attr('moment-date'),
|
createdAt: attr('moment-date'),
|
||||||
created_by: attr(),
|
createdBy: attr(),
|
||||||
tags: hasMany('tag', {
|
tags: hasMany('tag', {
|
||||||
embedded: 'always',
|
embedded: 'always',
|
||||||
async: false
|
async: false
|
||||||
@ -81,7 +81,7 @@ export default Model.extend(ValidationEngine, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
isAuthoredByUser(user) {
|
isAuthoredByUser(user) {
|
||||||
return parseInt(user.get('id'), 10) === parseInt(this.get('author_id'), 10);
|
return parseInt(user.get('id'), 10) === parseInt(this.get('authorId'), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -9,10 +9,10 @@ export default Model.extend({
|
|||||||
uuid: attr('string'),
|
uuid: attr('string'),
|
||||||
name: attr('string'),
|
name: attr('string'),
|
||||||
description: attr('string'),
|
description: attr('string'),
|
||||||
created_at: attr('moment-date'),
|
createdAt: attr('moment-date'),
|
||||||
updated_at: attr('moment-date'),
|
updatedAt: attr('moment-date'),
|
||||||
created_by: attr(),
|
createdBy: attr(),
|
||||||
updated_by: attr(),
|
updatedBy: attr(),
|
||||||
|
|
||||||
lowerCaseName: computed('name', function () {
|
lowerCaseName: computed('name', function () {
|
||||||
return this.get('name').toLocaleLowerCase();
|
return this.get('name').toLocaleLowerCase();
|
||||||
|
@ -11,13 +11,13 @@ export default Model.extend(ValidationEngine, {
|
|||||||
slug: attr('string'),
|
slug: attr('string'),
|
||||||
description: attr('string'),
|
description: attr('string'),
|
||||||
parent: attr(),
|
parent: attr(),
|
||||||
meta_title: attr('string'),
|
metaTitle: attr('string'),
|
||||||
meta_description: attr('string'),
|
metaDescription: attr('string'),
|
||||||
image: attr('string'),
|
image: attr('string'),
|
||||||
hidden: attr('boolean'),
|
hidden: attr('boolean'),
|
||||||
created_at: attr('moment-date'),
|
createdAt: attr('moment-date'),
|
||||||
updated_at: attr('moment-date'),
|
updatedAt: attr('moment-date'),
|
||||||
created_by: attr(),
|
createdBy: attr(),
|
||||||
updated_by: attr(),
|
updatedBy: attr(),
|
||||||
count: attr('raw')
|
count: attr('raw')
|
||||||
});
|
});
|
||||||
|
@ -26,13 +26,13 @@ export default Model.extend(ValidationEngine, {
|
|||||||
accessibility: attr('string'),
|
accessibility: attr('string'),
|
||||||
status: attr('string'),
|
status: attr('string'),
|
||||||
language: attr('string', {defaultValue: 'en_US'}),
|
language: attr('string', {defaultValue: 'en_US'}),
|
||||||
meta_title: attr('string'),
|
metaTitle: attr('string'),
|
||||||
meta_description: attr('string'),
|
metaDescription: attr('string'),
|
||||||
last_login: attr('moment-date'),
|
lastLogin: attr('moment-date'),
|
||||||
created_at: attr('moment-date'),
|
createdAt: attr('moment-date'),
|
||||||
created_by: attr('number'),
|
createdBy: attr('number'),
|
||||||
updated_at: attr('moment-date'),
|
updatedAt: attr('moment-date'),
|
||||||
updated_by: attr('number'),
|
updatedBy: attr('number'),
|
||||||
roles: hasMany('role', {
|
roles: hasMany('role', {
|
||||||
embedded: 'always',
|
embedded: 'always',
|
||||||
async: false
|
async: false
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
import RESTSerializer from 'ember-data/serializers/rest';
|
import RESTSerializer from 'ember-data/serializers/rest';
|
||||||
|
|
||||||
|
const {
|
||||||
|
decamelize
|
||||||
|
} = Ember.String;
|
||||||
|
|
||||||
export default RESTSerializer.extend({
|
export default RESTSerializer.extend({
|
||||||
serializeIntoHash(hash, type, record, options) {
|
serializeIntoHash(hash, type, record, options) {
|
||||||
// Our API expects an id on the posted object
|
// Our API expects an id on the posted object
|
||||||
@ -15,5 +19,9 @@ export default RESTSerializer.extend({
|
|||||||
delete data.uuid;
|
delete data.uuid;
|
||||||
|
|
||||||
hash[root] = [data];
|
hash[root] = [data];
|
||||||
|
},
|
||||||
|
|
||||||
|
keyForAttribute(attr) {
|
||||||
|
return decamelize(attr);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -12,10 +12,10 @@ export default ApplicationSerializer.extend(EmbeddedRecordsMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
normalize(typeClass, hash, prop) {
|
normalize(typeClass, hash, prop) {
|
||||||
// this is to enable us to still access the raw author_id
|
// this is to enable us to still access the raw authorId
|
||||||
// without requiring an extra get request (since it is an
|
// without requiring an extra get request (since it is an
|
||||||
// async relationship).
|
// async relationship).
|
||||||
hash.author_id = hash.author;
|
hash.authorId = hash.author;
|
||||||
|
|
||||||
return this._super(typeClass, hash, prop);
|
return this._super(typeClass, hash, prop);
|
||||||
},
|
},
|
||||||
@ -47,7 +47,7 @@ export default ApplicationSerializer.extend(EmbeddedRecordsMixin, {
|
|||||||
delete data.uuid;
|
delete data.uuid;
|
||||||
delete data.html;
|
delete data.html;
|
||||||
// Inserted locally as a convenience.
|
// Inserted locally as a convenience.
|
||||||
delete data.author_id;
|
delete data.authorId;
|
||||||
// Read-only virtual property.
|
// Read-only virtual property.
|
||||||
delete data.url;
|
delete data.url;
|
||||||
|
|
||||||
|
@ -30,6 +30,10 @@ export default ApplicationSerializer.extend({
|
|||||||
return this._super(store, primaryModelClass, payload, id, requestType);
|
return this._super(store, primaryModelClass, payload, id, requestType);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
keyForAttribute(attr) {
|
||||||
|
return attr;
|
||||||
|
},
|
||||||
|
|
||||||
_extractObjectFromArrayPayload(_payload) {
|
_extractObjectFromArrayPayload(_payload) {
|
||||||
let payload = {id: '0'};
|
let payload = {id: '0'};
|
||||||
|
|
||||||
|
@ -57,17 +57,17 @@
|
|||||||
|
|
||||||
<div class="settings-menu-content">
|
<div class="settings-menu-content">
|
||||||
<form>
|
<form>
|
||||||
{{#gh-form-group errors=tag.errors hasValidated=tag.hasValidated property="meta_title"}}
|
{{#gh-form-group errors=tag.errors hasValidated=tag.hasValidated property="metaTitle"}}
|
||||||
<label for="meta-title">Meta Title</label>
|
<label for="meta-title">Meta Title</label>
|
||||||
{{gh-input id="meta-title" name="meta_title" type="text" value=scratchMetaTitle focus-out=(action 'setProperty' 'meta_title')}}
|
{{gh-input id="meta-title" name="metaTitle" type="text" value=scratchMetaTitle focus-out=(action 'setProperty' 'metaTitle')}}
|
||||||
{{gh-error-message errors=tag.errors property="meta_title"}}
|
{{gh-error-message errors=tag.errors property="metaTitle"}}
|
||||||
<p>Recommended: <b>70</b> characters. You’ve used {{gh-count-down-characters scratchMetaTitle 70}}</p>
|
<p>Recommended: <b>70</b> characters. You’ve used {{gh-count-down-characters scratchMetaTitle 70}}</p>
|
||||||
{{/gh-form-group}}
|
{{/gh-form-group}}
|
||||||
|
|
||||||
{{#gh-form-group errors=tag.errors hasValidated=tag.hasValidated property="meta_description"}}
|
{{#gh-form-group errors=tag.errors hasValidated=tag.hasValidated property="metaDescription"}}
|
||||||
<label for="meta-description">Meta Description</label>
|
<label for="meta-description">Meta Description</label>
|
||||||
{{gh-textarea id="meta-description" name="meta_description" value=scratchMetaDescription focus-out=(action 'setProperty' 'meta_description')}}
|
{{gh-textarea id="meta-description" name="metaDescription" value=scratchMetaDescription focus-out=(action 'setProperty' 'metaDescription')}}
|
||||||
{{gh-error-message errors=tag.errors property="meta_description"}}
|
{{gh-error-message errors=tag.errors property="metaDescription"}}
|
||||||
<p>Recommended: <b>156</b> characters. You’ve used {{gh-count-down-characters scratchMetaDescription 156}}</p>
|
<p>Recommended: <b>156</b> characters. You’ve used {{gh-count-down-characters scratchMetaDescription 156}}</p>
|
||||||
{{/gh-form-group}}
|
{{/gh-form-group}}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
{{#gh-form-group errors=model.errors property="post-setting-date"}}
|
{{#gh-form-group errors=model.errors property="post-setting-date"}}
|
||||||
<label for="post-setting-date">Publish Date</label>
|
<label for="post-setting-date">Publish Date</label>
|
||||||
{{gh-datetime-input value=model.published_at
|
{{gh-datetime-input value=model.publishedAt
|
||||||
update=(action "setPublishedAt")
|
update=(action "setPublishedAt")
|
||||||
inputClass="post-setting-date"
|
inputClass="post-setting-date"
|
||||||
inputId="post-setting-date"
|
inputId="post-setting-date"
|
||||||
@ -109,18 +109,18 @@
|
|||||||
|
|
||||||
<div class="settings-menu-content">
|
<div class="settings-menu-content">
|
||||||
<form {{action "discardEnter" on="submit"}}>
|
<form {{action "discardEnter" on="submit"}}>
|
||||||
{{#gh-form-group errors=model.errors property="meta_title"}}
|
{{#gh-form-group errors=model.errors property="metaTitle"}}
|
||||||
<label for="meta-title">Meta Title</label>
|
<label for="meta-title">Meta Title</label>
|
||||||
{{gh-input class="post-setting-meta-title" id="meta-title" value=metaTitleScratch name="post-setting-meta-title" focus-out="setMetaTitle" stopEnterKeyDownPropagation="true"}}
|
{{gh-input class="post-setting-meta-title" id="meta-title" value=metaTitleScratch name="post-setting-meta-title" focus-out="setMetaTitle" stopEnterKeyDownPropagation="true"}}
|
||||||
<p>Recommended: <b>70</b> characters. You’ve used {{gh-count-down-characters metaTitleScratch 70}}</p>
|
<p>Recommended: <b>70</b> characters. You’ve used {{gh-count-down-characters metaTitleScratch 70}}</p>
|
||||||
{{gh-error-message errors=model.errors property="meta_title"}}
|
{{gh-error-message errors=model.errors property="metaTitle"}}
|
||||||
{{/gh-form-group}}
|
{{/gh-form-group}}
|
||||||
|
|
||||||
{{#gh-form-group errors=model.errors property="meta_description"}}
|
{{#gh-form-group errors=model.errors property="metaDescription"}}
|
||||||
<label for="meta-description">Meta Description</label>
|
<label for="meta-description">Meta Description</label>
|
||||||
{{gh-textarea class="gh-input post-setting-meta-description" id="meta-description" value=metaDescriptionScratch name="post-setting-meta-description" focus-out="setMetaDescription" stopEnterKeyDownPropagation="true"}}
|
{{gh-textarea class="gh-input post-setting-meta-description" id="meta-description" value=metaDescriptionScratch name="post-setting-meta-description" focus-out="setMetaDescription" stopEnterKeyDownPropagation="true"}}
|
||||||
<p>Recommended: <b>156</b> characters. You’ve used {{gh-count-down-characters metaDescriptionScratch 156}}</p>
|
<p>Recommended: <b>156</b> characters. You’ve used {{gh-count-down-characters metaDescriptionScratch 156}}</p>
|
||||||
{{gh-error-message errors=model.errors property="meta_description"}}
|
{{gh-error-message errors=model.errors property="metaDescription"}}
|
||||||
{{/gh-form-group}}
|
{{/gh-form-group}}
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
{{#if post.page}}
|
{{#if post.page}}
|
||||||
<span class="page">Page</span>
|
<span class="page">Page</span>
|
||||||
{{else}}
|
{{else}}
|
||||||
<time datetime="{{post.published_at}}" class="date published">
|
<time datetime="{{post.publishedAt}}" class="date published">
|
||||||
Published {{gh-format-timeago post.published_at}}
|
Published {{gh-format-timeago post.publishedAt}}
|
||||||
</time>
|
</time>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
|
@ -18,19 +18,19 @@ export default BaseValidator.create({
|
|||||||
},
|
},
|
||||||
|
|
||||||
metaTitle(model) {
|
metaTitle(model) {
|
||||||
let metaTitle = model.get('meta_title');
|
let metaTitle = model.get('metaTitle');
|
||||||
|
|
||||||
if (!validator.isLength(metaTitle, 0, 150)) {
|
if (!validator.isLength(metaTitle, 0, 150)) {
|
||||||
model.get('errors').add('meta_title', 'Meta Title cannot be longer than 150 characters.');
|
model.get('errors').add('metaTitle', 'Meta Title cannot be longer than 150 characters.');
|
||||||
this.invalidate();
|
this.invalidate();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
metaDescription(model) {
|
metaDescription(model) {
|
||||||
let metaDescription = model.get('meta_description');
|
let metaDescription = model.get('metaDescription');
|
||||||
|
|
||||||
if (!validator.isLength(metaDescription, 0, 200)) {
|
if (!validator.isLength(metaDescription, 0, 200)) {
|
||||||
model.get('errors').add('meta_description', 'Meta Description cannot be longer than 200 characters.');
|
model.get('errors').add('metaDescription', 'Meta Description cannot be longer than 200 characters.');
|
||||||
this.invalidate();
|
this.invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,19 +37,19 @@ export default BaseValidator.create({
|
|||||||
},
|
},
|
||||||
|
|
||||||
metaTitle(model) {
|
metaTitle(model) {
|
||||||
let metaTitle = model.get('meta_title');
|
let metaTitle = model.get('metaTitle');
|
||||||
|
|
||||||
if (!validator.isLength(metaTitle, 0, 150)) {
|
if (!validator.isLength(metaTitle, 0, 150)) {
|
||||||
model.get('errors').add('meta_title', 'Meta Title cannot be longer than 150 characters.');
|
model.get('errors').add('metaTitle', 'Meta Title cannot be longer than 150 characters.');
|
||||||
this.invalidate();
|
this.invalidate();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
metaDescription(model) {
|
metaDescription(model) {
|
||||||
let metaDescription = model.get('meta_description');
|
let metaDescription = model.get('metaDescription');
|
||||||
|
|
||||||
if (!validator.isLength(metaDescription, 0, 200)) {
|
if (!validator.isLength(metaDescription, 0, 200)) {
|
||||||
model.get('errors').add('meta_description', 'Meta Description cannot be longer than 200 characters.');
|
model.get('errors').add('metaDescription', 'Meta Description cannot be longer than 200 characters.');
|
||||||
this.invalidate();
|
this.invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,8 @@ describeComponent(
|
|||||||
name: 'Test',
|
name: 'Test',
|
||||||
slug: 'test',
|
slug: 'test',
|
||||||
description: 'Description.',
|
description: 'Description.',
|
||||||
meta_title: 'Meta Title',
|
metaTitle: 'Meta Title',
|
||||||
meta_description: 'Meta description',
|
metaDescription: 'Meta description',
|
||||||
errors: DS.Errors.create(),
|
errors: DS.Errors.create(),
|
||||||
hasValidated: []
|
hasValidated: []
|
||||||
});
|
});
|
||||||
@ -72,8 +72,8 @@ describeComponent(
|
|||||||
expect(this.$('input[name="name"]').val(), 'name field value').to.equal('Test');
|
expect(this.$('input[name="name"]').val(), 'name field value').to.equal('Test');
|
||||||
expect(this.$('input[name="slug"]').val(), 'slug field value').to.equal('test');
|
expect(this.$('input[name="slug"]').val(), 'slug field value').to.equal('test');
|
||||||
expect(this.$('textarea[name="description"]').val(), 'description field value').to.equal('Description.');
|
expect(this.$('textarea[name="description"]').val(), 'description field value').to.equal('Description.');
|
||||||
expect(this.$('input[name="meta_title"]').val(), 'meta_title field value').to.equal('Meta Title');
|
expect(this.$('input[name="metaTitle"]').val(), 'metaTitle field value').to.equal('Meta Title');
|
||||||
expect(this.$('textarea[name="meta_description"]').val(), 'meta_description field value').to.equal('Meta description');
|
expect(this.$('textarea[name="metaDescription"]').val(), 'metaDescription field value').to.equal('Meta description');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can switch between main/meta settings', function () {
|
it('can switch between main/meta settings', function () {
|
||||||
@ -112,15 +112,15 @@ describeComponent(
|
|||||||
this.$('input[name="name"]').val('New name');
|
this.$('input[name="name"]').val('New name');
|
||||||
this.$('input[name="slug"]').val('new-slug');
|
this.$('input[name="slug"]').val('new-slug');
|
||||||
this.$('textarea[name="description"]').val('New description');
|
this.$('textarea[name="description"]').val('New description');
|
||||||
this.$('input[name="meta_title"]').val('New meta_title');
|
this.$('input[name="metaTitle"]').val('New metaTitle');
|
||||||
this.$('textarea[name="meta_description"]').val('New meta_description');
|
this.$('textarea[name="metaDescription"]').val('New metaDescription');
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(this.get('tag.name'), 'tag name').to.equal('Test');
|
expect(this.get('tag.name'), 'tag name').to.equal('Test');
|
||||||
expect(this.get('tag.slug'), 'tag slug').to.equal('test');
|
expect(this.get('tag.slug'), 'tag slug').to.equal('test');
|
||||||
expect(this.get('tag.description'), 'tag description').to.equal('Description.');
|
expect(this.get('tag.description'), 'tag description').to.equal('Description.');
|
||||||
expect(this.get('tag.meta_title'), 'tag meta_title').to.equal('Meta Title');
|
expect(this.get('tag.metaTitle'), 'tag metaTitle').to.equal('Meta Title');
|
||||||
expect(this.get('tag.meta_description'), 'tag meta_description').to.equal('Meta description');
|
expect(this.get('tag.metaDescription'), 'tag metaDescription').to.equal('Meta description');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('triggers setProperty action on blur of all fields', function () {
|
it('triggers setProperty action on blur of all fields', function () {
|
||||||
@ -154,16 +154,16 @@ describeComponent(
|
|||||||
this.$('textarea[name="description"]').val('New description');
|
this.$('textarea[name="description"]').val('New description');
|
||||||
});
|
});
|
||||||
|
|
||||||
expectedProperty = 'meta_title';
|
expectedProperty = 'metaTitle';
|
||||||
expectedValue = 'New meta_title';
|
expectedValue = 'New metaTitle';
|
||||||
run(() => {
|
run(() => {
|
||||||
this.$('input[name="meta_title"]').val('New meta_title');
|
this.$('input[name="metaTitle"]').val('New metaTitle');
|
||||||
});
|
});
|
||||||
|
|
||||||
expectedProperty = 'meta_description';
|
expectedProperty = 'metaDescription';
|
||||||
expectedValue = 'New meta_description';
|
expectedValue = 'New metaDescription';
|
||||||
run(() => {
|
run(() => {
|
||||||
this.$('textarea[name="meta_description"]').val('New meta_description');
|
this.$('textarea[name="metaDescription"]').val('New metaDescription');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -180,11 +180,11 @@ describeComponent(
|
|||||||
errors.add('description', 'is too long');
|
errors.add('description', 'is too long');
|
||||||
hasValidated.push('description');
|
hasValidated.push('description');
|
||||||
|
|
||||||
errors.add('meta_title', 'is too long');
|
errors.add('metaTitle', 'is too long');
|
||||||
hasValidated.push('meta_title');
|
hasValidated.push('metaTitle');
|
||||||
|
|
||||||
errors.add('meta_description', 'is too long');
|
errors.add('metaDescription', 'is too long');
|
||||||
hasValidated.push('meta_description');
|
hasValidated.push('metaDescription');
|
||||||
|
|
||||||
this.render(hbs`
|
this.render(hbs`
|
||||||
{{gh-tag-settings-form tag=tag setProperty=(action 'setProperty')}}
|
{{gh-tag-settings-form tag=tag setProperty=(action 'setProperty')}}
|
||||||
@ -201,13 +201,13 @@ describeComponent(
|
|||||||
let descriptionFormGroup = this.$('textarea[name="description"]').closest('.form-group');
|
let descriptionFormGroup = this.$('textarea[name="description"]').closest('.form-group');
|
||||||
expect(descriptionFormGroup.hasClass('error'), 'description form group has error state').to.be.true;
|
expect(descriptionFormGroup.hasClass('error'), 'description form group has error state').to.be.true;
|
||||||
|
|
||||||
let metaTitleFormGroup = this.$('input[name="meta_title"]').closest('.form-group');
|
let metaTitleFormGroup = this.$('input[name="metaTitle"]').closest('.form-group');
|
||||||
expect(metaTitleFormGroup.hasClass('error'), 'meta_title form group has error state').to.be.true;
|
expect(metaTitleFormGroup.hasClass('error'), 'metaTitle form group has error state').to.be.true;
|
||||||
expect(metaTitleFormGroup.find('.response').length, 'meta_title form group has error message').to.equal(1);
|
expect(metaTitleFormGroup.find('.response').length, 'metaTitle form group has error message').to.equal(1);
|
||||||
|
|
||||||
let metaDescriptionFormGroup = this.$('textarea[name="meta_description"]').closest('.form-group');
|
let metaDescriptionFormGroup = this.$('textarea[name="metaDescription"]').closest('.form-group');
|
||||||
expect(metaDescriptionFormGroup.hasClass('error'), 'meta_description form group has error state').to.be.true;
|
expect(metaDescriptionFormGroup.hasClass('error'), 'metaDescription form group has error state').to.be.true;
|
||||||
expect(metaDescriptionFormGroup.find('.response').length, 'meta_description form group has error message').to.equal(1);
|
expect(metaDescriptionFormGroup.find('.response').length, 'metaDescription form group has error message').to.equal(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('displays char count for text fields', function () {
|
it('displays char count for text fields', function () {
|
||||||
@ -218,7 +218,7 @@ describeComponent(
|
|||||||
let descriptionFormGroup = this.$('textarea[name="description"]').closest('.form-group');
|
let descriptionFormGroup = this.$('textarea[name="description"]').closest('.form-group');
|
||||||
expect(descriptionFormGroup.find('.word-count').text(), 'description char count').to.equal('12');
|
expect(descriptionFormGroup.find('.word-count').text(), 'description char count').to.equal('12');
|
||||||
|
|
||||||
let metaDescriptionFormGroup = this.$('textarea[name="meta_description"]').closest('.form-group');
|
let metaDescriptionFormGroup = this.$('textarea[name="metaDescription"]').closest('.form-group');
|
||||||
expect(metaDescriptionFormGroup.find('.word-count').text(), 'description char count').to.equal('16');
|
expect(metaDescriptionFormGroup.find('.word-count').text(), 'description char count').to.equal('16');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -229,9 +229,9 @@ describeComponent(
|
|||||||
expect(this.$('.seo-preview-title').text(), 'displays meta title if present').to.equal('Meta Title');
|
expect(this.$('.seo-preview-title').text(), 'displays meta title if present').to.equal('Meta Title');
|
||||||
|
|
||||||
run(() => {
|
run(() => {
|
||||||
this.set('tag.meta_title', '');
|
this.set('tag.metaTitle', '');
|
||||||
});
|
});
|
||||||
expect(this.$('.seo-preview-title').text(), 'falls back to tag name without meta_title').to.equal('Test');
|
expect(this.$('.seo-preview-title').text(), 'falls back to tag name without metaTitle').to.equal('Test');
|
||||||
|
|
||||||
run(() => {
|
run(() => {
|
||||||
this.set('tag.name', (new Array(151).join('x')));
|
this.set('tag.name', (new Array(151).join('x')));
|
||||||
@ -260,9 +260,9 @@ describeComponent(
|
|||||||
expect(this.$('.seo-preview-description').text(), 'displays meta description if present').to.equal('Meta description');
|
expect(this.$('.seo-preview-description').text(), 'displays meta description if present').to.equal('Meta description');
|
||||||
|
|
||||||
run(() => {
|
run(() => {
|
||||||
this.set('tag.meta_description', '');
|
this.set('tag.metaDescription', '');
|
||||||
});
|
});
|
||||||
expect(this.$('.seo-preview-description').text(), 'falls back to tag description without meta_description').to.equal('Description.');
|
expect(this.$('.seo-preview-description').text(), 'falls back to tag description without metaDescription').to.equal('Description.');
|
||||||
|
|
||||||
run(() => {
|
run(() => {
|
||||||
this.set('tag.description', (new Array(200).join('x')));
|
this.set('tag.description', (new Array(200).join('x')));
|
||||||
|
@ -50,18 +50,18 @@ describeModule(
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('metaTitleScratch is one-way bound to model.meta_title', function () {
|
it('metaTitleScratch is one-way bound to model.metaTitle', function () {
|
||||||
let controller = this.subject({
|
let controller = this.subject({
|
||||||
model: Ember.Object.create({
|
model: Ember.Object.create({
|
||||||
meta_title: 'a title'
|
metaTitle: 'a title'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(controller.get('model.meta_title')).to.equal('a title');
|
expect(controller.get('model.metaTitle')).to.equal('a title');
|
||||||
expect(controller.get('metaTitleScratch')).to.equal('a title');
|
expect(controller.get('metaTitleScratch')).to.equal('a title');
|
||||||
|
|
||||||
run(function () {
|
run(function () {
|
||||||
controller.set('model.meta_title', 'a different title');
|
controller.set('model.metaTitle', 'a different title');
|
||||||
|
|
||||||
expect(controller.get('metaTitleScratch')).to.equal('a different title');
|
expect(controller.get('metaTitleScratch')).to.equal('a different title');
|
||||||
});
|
});
|
||||||
@ -69,30 +69,30 @@ describeModule(
|
|||||||
run(function () {
|
run(function () {
|
||||||
controller.set('metaTitleScratch', 'changed directly');
|
controller.set('metaTitleScratch', 'changed directly');
|
||||||
|
|
||||||
expect(controller.get('model.meta_title')).to.equal('a different title');
|
expect(controller.get('model.metaTitle')).to.equal('a different title');
|
||||||
expect(controller.get('metaTitleScratch')).to.equal('changed directly');
|
expect(controller.get('metaTitleScratch')).to.equal('changed directly');
|
||||||
});
|
});
|
||||||
|
|
||||||
run(function () {
|
run(function () {
|
||||||
// test that the one-way binding is still in place
|
// test that the one-way binding is still in place
|
||||||
controller.set('model.meta_title', 'should update');
|
controller.set('model.metaTitle', 'should update');
|
||||||
|
|
||||||
expect(controller.get('metaTitleScratch')).to.equal('should update');
|
expect(controller.get('metaTitleScratch')).to.equal('should update');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('metaDescriptionScratch is one-way bound to model.meta_description', function () {
|
it('metaDescriptionScratch is one-way bound to model.metaDescription', function () {
|
||||||
let controller = this.subject({
|
let controller = this.subject({
|
||||||
model: Ember.Object.create({
|
model: Ember.Object.create({
|
||||||
meta_description: 'a description'
|
metaDescription: 'a description'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(controller.get('model.meta_description')).to.equal('a description');
|
expect(controller.get('model.metaDescription')).to.equal('a description');
|
||||||
expect(controller.get('metaDescriptionScratch')).to.equal('a description');
|
expect(controller.get('metaDescriptionScratch')).to.equal('a description');
|
||||||
|
|
||||||
run(function () {
|
run(function () {
|
||||||
controller.set('model.meta_description', 'a different description');
|
controller.set('model.metaDescription', 'a different description');
|
||||||
|
|
||||||
expect(controller.get('metaDescriptionScratch')).to.equal('a different description');
|
expect(controller.get('metaDescriptionScratch')).to.equal('a different description');
|
||||||
});
|
});
|
||||||
@ -100,23 +100,23 @@ describeModule(
|
|||||||
run(function () {
|
run(function () {
|
||||||
controller.set('metaDescriptionScratch', 'changed directly');
|
controller.set('metaDescriptionScratch', 'changed directly');
|
||||||
|
|
||||||
expect(controller.get('model.meta_description')).to.equal('a different description');
|
expect(controller.get('model.metaDescription')).to.equal('a different description');
|
||||||
expect(controller.get('metaDescriptionScratch')).to.equal('changed directly');
|
expect(controller.get('metaDescriptionScratch')).to.equal('changed directly');
|
||||||
});
|
});
|
||||||
|
|
||||||
run(function () {
|
run(function () {
|
||||||
// test that the one-way binding is still in place
|
// test that the one-way binding is still in place
|
||||||
controller.set('model.meta_description', 'should update');
|
controller.set('model.metaDescription', 'should update');
|
||||||
|
|
||||||
expect(controller.get('metaDescriptionScratch')).to.equal('should update');
|
expect(controller.get('metaDescriptionScratch')).to.equal('should update');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('seoTitle', function () {
|
describe('seoTitle', function () {
|
||||||
it('should be the meta_title if one exists', function () {
|
it('should be the metaTitle if one exists', function () {
|
||||||
let controller = this.subject({
|
let controller = this.subject({
|
||||||
model: Ember.Object.create({
|
model: Ember.Object.create({
|
||||||
meta_title: 'a meta-title',
|
metaTitle: 'a meta-title',
|
||||||
titleScratch: 'should not be used'
|
titleScratch: 'should not be used'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@ -134,10 +134,10 @@ describeModule(
|
|||||||
expect(controller.get('seoTitle')).to.equal('should be the meta-title');
|
expect(controller.get('seoTitle')).to.equal('should be the meta-title');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be the meta_title if both title and meta_title exist', function () {
|
it('should be the metaTitle if both title and metaTitle exist', function () {
|
||||||
let controller = this.subject({
|
let controller = this.subject({
|
||||||
model: Ember.Object.create({
|
model: Ember.Object.create({
|
||||||
meta_title: 'a meta-title',
|
metaTitle: 'a meta-title',
|
||||||
titleScratch: 'a title'
|
titleScratch: 'a title'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@ -145,10 +145,10 @@ describeModule(
|
|||||||
expect(controller.get('seoTitle')).to.equal('a meta-title');
|
expect(controller.get('seoTitle')).to.equal('a meta-title');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should revert to the title if explicit meta_title is removed', function () {
|
it('should revert to the title if explicit metaTitle is removed', function () {
|
||||||
let controller = this.subject({
|
let controller = this.subject({
|
||||||
model: Ember.Object.create({
|
model: Ember.Object.create({
|
||||||
meta_title: 'a meta-title',
|
metaTitle: 'a meta-title',
|
||||||
titleScratch: 'a title'
|
titleScratch: 'a title'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@ -156,7 +156,7 @@ describeModule(
|
|||||||
expect(controller.get('seoTitle')).to.equal('a meta-title');
|
expect(controller.get('seoTitle')).to.equal('a meta-title');
|
||||||
|
|
||||||
run(function () {
|
run(function () {
|
||||||
controller.set('model.meta_title', '');
|
controller.set('model.metaTitle', '');
|
||||||
|
|
||||||
expect(controller.get('seoTitle')).to.equal('a title');
|
expect(controller.get('seoTitle')).to.equal('a title');
|
||||||
});
|
});
|
||||||
@ -182,10 +182,10 @@ describeModule(
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('seoDescription', function () {
|
describe('seoDescription', function () {
|
||||||
it('should be the meta_description if one exists', function () {
|
it('should be the metaDescription if one exists', function () {
|
||||||
let controller = this.subject({
|
let controller = this.subject({
|
||||||
model: Ember.Object.create({
|
model: Ember.Object.create({
|
||||||
meta_description: 'a description'
|
metaDescription: 'a description'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ describeModel(
|
|||||||
it('isAuthoredByUser is correct', function () {
|
it('isAuthoredByUser is correct', function () {
|
||||||
/* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
|
/* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
|
||||||
let model = this.subject({
|
let model = this.subject({
|
||||||
author_id: 15
|
authorId: 15
|
||||||
});
|
});
|
||||||
/* jscs:enable requireCamelCaseOrUpperCaseIdentifiers */
|
/* jscs:enable requireCamelCaseOrUpperCaseIdentifiers */
|
||||||
let user = Ember.Object.create({id: '15'});
|
let user = Ember.Object.create({id: '15'});
|
||||||
@ -45,7 +45,7 @@ describeModel(
|
|||||||
expect(model.isAuthoredByUser(user)).to.be.ok;
|
expect(model.isAuthoredByUser(user)).to.be.ok;
|
||||||
|
|
||||||
Ember.run(function () {
|
Ember.run(function () {
|
||||||
model.set('author_id', 1);
|
model.set('authorId', 1);
|
||||||
|
|
||||||
expect(model.isAuthoredByUser(user)).to.not.be.ok;
|
expect(model.isAuthoredByUser(user)).to.not.be.ok;
|
||||||
});
|
});
|
||||||
|
@ -17,8 +17,8 @@ const Tag = Ember.Object.extend(ValidationEngine, {
|
|||||||
|
|
||||||
name: null,
|
name: null,
|
||||||
description: null,
|
description: null,
|
||||||
meta_title: null,
|
metaTitle: null,
|
||||||
meta_description: null
|
metaDescription: null
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: These tests have way too much duplication, consider creating test
|
// TODO: These tests have way too much duplication, consider creating test
|
||||||
@ -224,14 +224,14 @@ describe('Unit: Validator: tag-settings', function () {
|
|||||||
expect(tag.get('hasValidated'), 'hasValidated').to.include('description');
|
expect(tag.get('hasValidated'), 'hasValidated').to.include('description');
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: we have both meta_title and metaTitle property names on the
|
// TODO: we have both metaTitle and metaTitle property names on the
|
||||||
// model/validator respectively - this should be standardised
|
// model/validator respectively - this should be standardised
|
||||||
it('passes with a valid meta_title', function () {
|
it('passes with a valid metaTitle', function () {
|
||||||
// longest valid meta_title
|
// longest valid metaTitle
|
||||||
const tag = Tag.create({meta_title: (new Array(151).join('x'))});
|
const tag = Tag.create({metaTitle: (new Array(151).join('x'))});
|
||||||
let passed = false;
|
let passed = false;
|
||||||
|
|
||||||
expect(tag.get('meta_title').length, 'meta_title length').to.equal(150);
|
expect(tag.get('metaTitle').length, 'metaTitle length').to.equal(150);
|
||||||
|
|
||||||
run(() => {
|
run(() => {
|
||||||
tag.validate({property: 'metaTitle'}).then(() => {
|
tag.validate({property: 'metaTitle'}).then(() => {
|
||||||
@ -243,13 +243,13 @@ describe('Unit: Validator: tag-settings', function () {
|
|||||||
expect(tag.get('hasValidated'), 'hasValidated').to.include('metaTitle');
|
expect(tag.get('hasValidated'), 'hasValidated').to.include('metaTitle');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('validates meta_title length', function () {
|
it('validates metaTitle length', function () {
|
||||||
// shortest invalid meta_title
|
// shortest invalid metaTitle
|
||||||
const tag = Tag.create({meta_title: (new Array(152).join('x'))});
|
const tag = Tag.create({metaTitle: (new Array(152).join('x'))});
|
||||||
let passed = false;
|
let passed = false;
|
||||||
let errors;
|
let errors;
|
||||||
|
|
||||||
expect(tag.get('meta_title').length, 'meta_title length').to.equal(151);
|
expect(tag.get('metaTitle').length, 'metaTitle length').to.equal(151);
|
||||||
|
|
||||||
run(() => {
|
run(() => {
|
||||||
tag.validate({property: 'metaTitle'}).then(() => {
|
tag.validate({property: 'metaTitle'}).then(() => {
|
||||||
@ -257,22 +257,22 @@ describe('Unit: Validator: tag-settings', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
errors = tag.get('errors').errorsFor('meta_title')[0];
|
errors = tag.get('errors').errorsFor('metaTitle')[0];
|
||||||
expect(errors.attribute, 'errors.meta_title.attribute').to.equal('meta_title');
|
expect(errors.attribute, 'errors.metaTitle.attribute').to.equal('metaTitle');
|
||||||
expect(errors.message, 'errors.meta_title.message').to.equal('Meta Title cannot be longer than 150 characters.');
|
expect(errors.message, 'errors.metaTitle.message').to.equal('Meta Title cannot be longer than 150 characters.');
|
||||||
|
|
||||||
expect(passed, 'passed').to.be.false;
|
expect(passed, 'passed').to.be.false;
|
||||||
expect(tag.get('hasValidated'), 'hasValidated').to.include('metaTitle');
|
expect(tag.get('hasValidated'), 'hasValidated').to.include('metaTitle');
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: we have both meta_description and metaDescription property names on
|
// TODO: we have both metaDescription and metaDescription property names on
|
||||||
// the model/validator respectively - this should be standardised
|
// the model/validator respectively - this should be standardised
|
||||||
it('passes with a valid meta_description', function () {
|
it('passes with a valid metaDescription', function () {
|
||||||
// longest valid description
|
// longest valid description
|
||||||
const tag = Tag.create({meta_description: (new Array(201).join('x'))});
|
const tag = Tag.create({metaDescription: (new Array(201).join('x'))});
|
||||||
let passed = false;
|
let passed = false;
|
||||||
|
|
||||||
expect(tag.get('meta_description').length, 'meta_description length').to.equal(200);
|
expect(tag.get('metaDescription').length, 'metaDescription length').to.equal(200);
|
||||||
|
|
||||||
run(() => {
|
run(() => {
|
||||||
tag.validate({property: 'metaDescription'}).then(() => {
|
tag.validate({property: 'metaDescription'}).then(() => {
|
||||||
@ -284,13 +284,13 @@ describe('Unit: Validator: tag-settings', function () {
|
|||||||
expect(tag.get('hasValidated'), 'hasValidated').to.include('metaDescription');
|
expect(tag.get('hasValidated'), 'hasValidated').to.include('metaDescription');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('validates meta_description length', function () {
|
it('validates metaDescription length', function () {
|
||||||
// shortest invalid meta_description
|
// shortest invalid metaDescription
|
||||||
const tag = Tag.create({meta_description: (new Array(202).join('x'))});
|
const tag = Tag.create({metaDescription: (new Array(202).join('x'))});
|
||||||
let passed = false;
|
let passed = false;
|
||||||
let errors;
|
let errors;
|
||||||
|
|
||||||
expect(tag.get('meta_description').length, 'meta_description length').to.equal(201);
|
expect(tag.get('metaDescription').length, 'metaDescription length').to.equal(201);
|
||||||
|
|
||||||
run(() => {
|
run(() => {
|
||||||
tag.validate({property: 'metaDescription'}).then(() => {
|
tag.validate({property: 'metaDescription'}).then(() => {
|
||||||
@ -298,9 +298,9 @@ describe('Unit: Validator: tag-settings', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
errors = tag.get('errors').errorsFor('meta_description')[0];
|
errors = tag.get('errors').errorsFor('metaDescription')[0];
|
||||||
expect(errors.attribute, 'errors.meta_description.attribute').to.equal('meta_description');
|
expect(errors.attribute, 'errors.metaDescription.attribute').to.equal('metaDescription');
|
||||||
expect(errors.message, 'errors.meta_description.message').to.equal('Meta Description cannot be longer than 200 characters.');
|
expect(errors.message, 'errors.metaDescription.message').to.equal('Meta Description cannot be longer than 200 characters.');
|
||||||
|
|
||||||
expect(passed, 'passed').to.be.false;
|
expect(passed, 'passed').to.be.false;
|
||||||
expect(tag.get('hasValidated'), 'hasValidated').to.include('metaDescription');
|
expect(tag.get('hasValidated'), 'hasValidated').to.include('metaDescription');
|
||||||
|
Loading…
Reference in New Issue
Block a user