mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 14:43:08 +03:00
Renamed preview
files to previews
refs https://github.com/TryGhost/Toolbox/issues/308 - we have a pattern of using plurals around Ghost but this was singular - this shouldn't change any API functionality, it's just code refactoring
This commit is contained in:
parent
0eedb1c556
commit
3b6cdc2bc5
@ -9,7 +9,7 @@ class PreviewRouter extends ParentRouter {
|
|||||||
constructor(RESOURCE_CONFIG) {
|
constructor(RESOURCE_CONFIG) {
|
||||||
super('PreviewRouter');
|
super('PreviewRouter');
|
||||||
|
|
||||||
this.RESOURCE_CONFIG = RESOURCE_CONFIG.QUERY.preview;
|
this.RESOURCE_CONFIG = RESOURCE_CONFIG.QUERY.previews;
|
||||||
|
|
||||||
// @NOTE: hardcoded, not configureable
|
// @NOTE: hardcoded, not configureable
|
||||||
this.route = {value: '/p/'};
|
this.route = {value: '/p/'};
|
||||||
@ -25,8 +25,8 @@ class PreviewRouter extends ParentRouter {
|
|||||||
// REGISTER: prepare context
|
// REGISTER: prepare context
|
||||||
this.router().use(this._prepareContext.bind(this));
|
this.router().use(this._prepareContext.bind(this));
|
||||||
|
|
||||||
// REGISTER: actual preview route
|
// REGISTER: actual previews route
|
||||||
this.mountRoute(urlUtils.urlJoin(this.route.value, ':uuid', ':options?'), controllers.preview);
|
this.mountRoute(urlUtils.urlJoin(this.route.value, ':uuid', ':options?'), controllers.previews);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,9 +32,9 @@ module.exports.QUERY = {
|
|||||||
slug: '%s'
|
slug: '%s'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
preview: {
|
previews: {
|
||||||
controller: 'preview',
|
controller: 'previews',
|
||||||
resource: 'preview'
|
resource: 'previews'
|
||||||
},
|
},
|
||||||
email: {
|
email: {
|
||||||
controller: 'emailPost',
|
controller: 'emailPost',
|
||||||
|
@ -11,8 +11,8 @@ module.exports = {
|
|||||||
return require('./rss');
|
return require('./rss');
|
||||||
},
|
},
|
||||||
|
|
||||||
get preview() {
|
get previews() {
|
||||||
return require('./preview');
|
return require('./previews');
|
||||||
},
|
},
|
||||||
|
|
||||||
get email() {
|
get email() {
|
||||||
|
@ -121,8 +121,8 @@ module.exports = {
|
|||||||
return shared.pipeline(require('./users'), localUtils);
|
return shared.pipeline(require('./users'), localUtils);
|
||||||
},
|
},
|
||||||
|
|
||||||
get preview() {
|
get previews() {
|
||||||
return shared.pipeline(require('./preview'), localUtils);
|
return shared.pipeline(require('./previews'), localUtils);
|
||||||
},
|
},
|
||||||
|
|
||||||
get emailPost() {
|
get emailPost() {
|
||||||
|
@ -8,7 +8,7 @@ const messages = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
docName: 'preview',
|
docName: 'previews',
|
||||||
|
|
||||||
read: {
|
read: {
|
||||||
permissions: true,
|
permissions: true,
|
@ -85,8 +85,8 @@ module.exports = {
|
|||||||
return require('./users');
|
return require('./users');
|
||||||
},
|
},
|
||||||
|
|
||||||
get preview() {
|
get previews() {
|
||||||
return require('./preview');
|
return require('./previews');
|
||||||
},
|
},
|
||||||
|
|
||||||
get email_post() {
|
get email_post() {
|
||||||
|
@ -10,8 +10,8 @@ module.exports = {
|
|||||||
|
|
||||||
const data = await mappers.posts(model, frame, {tiers});
|
const data = await mappers.posts(model, frame, {tiers});
|
||||||
frame.response = {
|
frame.response = {
|
||||||
preview: [data]
|
previews: [data]
|
||||||
};
|
};
|
||||||
frame.response.preview[0].page = model.get('type') === 'page';
|
frame.response.previews[0].page = model.get('type') === 'page';
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -5,7 +5,7 @@ const mappers = require('../../../../../../../core/server/api/canary/utils/seria
|
|||||||
const serializers = require('../../../../../../../core/server/api/canary/utils/serializers');
|
const serializers = require('../../../../../../../core/server/api/canary/utils/serializers');
|
||||||
const membersService = require('../../../../../../../core/server/services/members');
|
const membersService = require('../../../../../../../core/server/services/members');
|
||||||
|
|
||||||
describe('Unit: canary/utils/serializers/output/preview', function () {
|
describe('Unit: canary/utils/serializers/output/previews', function () {
|
||||||
let pageModel;
|
let pageModel;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
@ -46,11 +46,11 @@ describe('Unit: canary/utils/serializers/output/preview', function () {
|
|||||||
type: 'page'
|
type: 'page'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
await serializers.output.preview.all(ctrlResponse, apiConfig, frame);
|
await serializers.output.previews.all(ctrlResponse, apiConfig, frame);
|
||||||
|
|
||||||
mappers.posts.callCount.should.equal(1);
|
mappers.posts.callCount.should.equal(1);
|
||||||
mappers.posts.getCall(0).args.should.eql([ctrlResponse, frame, {tiers: []}]);
|
mappers.posts.getCall(0).args.should.eql([ctrlResponse, frame, {tiers: []}]);
|
||||||
|
|
||||||
frame.response.preview[0].page.should.equal(true);
|
frame.response.previews[0].page.should.equal(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -9,7 +9,7 @@ const renderer = require('../../../../../../core/frontend/services/rendering');
|
|||||||
const urlService = require('../../../../../../core/server/services/url');
|
const urlService = require('../../../../../../core/server/services/url');
|
||||||
const urlUtils = require('../../../../../../core/shared/url-utils');
|
const urlUtils = require('../../../../../../core/shared/url-utils');
|
||||||
|
|
||||||
describe('Unit - services/routing/controllers/preview', function () {
|
describe('Unit - services/routing/controllers/previews', function () {
|
||||||
let secureStub;
|
let secureStub;
|
||||||
let renderStub;
|
let renderStub;
|
||||||
let req;
|
let req;
|
||||||
@ -35,7 +35,7 @@ describe('Unit - services/routing/controllers/preview', function () {
|
|||||||
post = testUtils.DataGenerator.forKnex.createPost({status: 'draft'});
|
post = testUtils.DataGenerator.forKnex.createPost({status: 'draft'});
|
||||||
|
|
||||||
apiResponse = {
|
apiResponse = {
|
||||||
preview: [post]
|
previews: [post]
|
||||||
};
|
};
|
||||||
|
|
||||||
req = {
|
req = {
|
||||||
@ -48,7 +48,7 @@ describe('Unit - services/routing/controllers/preview', function () {
|
|||||||
|
|
||||||
res = {
|
res = {
|
||||||
routerOptions: {
|
routerOptions: {
|
||||||
query: {controller: 'preview', resource: 'preview'}
|
query: {controller: 'previews', resource: 'previews'}
|
||||||
},
|
},
|
||||||
locals: {},
|
locals: {},
|
||||||
render: sinon.spy(),
|
render: sinon.spy(),
|
||||||
@ -80,7 +80,7 @@ describe('Unit - services/routing/controllers/preview', function () {
|
|||||||
include: 'authors,tags,tiers'
|
include: 'authors,tags,tiers'
|
||||||
}).resolves(apiResponse);
|
}).resolves(apiResponse);
|
||||||
|
|
||||||
sinon.stub(api, 'preview').get(() => {
|
sinon.stub(api, 'previews').get(() => {
|
||||||
return {
|
return {
|
||||||
read: previewStub
|
read: previewStub
|
||||||
};
|
};
|
||||||
@ -88,7 +88,7 @@ describe('Unit - services/routing/controllers/preview', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should render post', function (done) {
|
it('should render post', function (done) {
|
||||||
controllers.preview(req, res, failTest(done)).then(function () {
|
controllers.previews(req, res, failTest(done)).then(function () {
|
||||||
renderStub.called.should.be.true();
|
renderStub.called.should.be.true();
|
||||||
secureStub.called.should.be.true();
|
secureStub.called.should.be.true();
|
||||||
done();
|
done();
|
Loading…
Reference in New Issue
Block a user