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) {
|
||||
super('PreviewRouter');
|
||||
|
||||
this.RESOURCE_CONFIG = RESOURCE_CONFIG.QUERY.preview;
|
||||
this.RESOURCE_CONFIG = RESOURCE_CONFIG.QUERY.previews;
|
||||
|
||||
// @NOTE: hardcoded, not configureable
|
||||
this.route = {value: '/p/'};
|
||||
@ -25,8 +25,8 @@ class PreviewRouter extends ParentRouter {
|
||||
// REGISTER: prepare context
|
||||
this.router().use(this._prepareContext.bind(this));
|
||||
|
||||
// REGISTER: actual preview route
|
||||
this.mountRoute(urlUtils.urlJoin(this.route.value, ':uuid', ':options?'), controllers.preview);
|
||||
// REGISTER: actual previews route
|
||||
this.mountRoute(urlUtils.urlJoin(this.route.value, ':uuid', ':options?'), controllers.previews);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,9 +32,9 @@ module.exports.QUERY = {
|
||||
slug: '%s'
|
||||
}
|
||||
},
|
||||
preview: {
|
||||
controller: 'preview',
|
||||
resource: 'preview'
|
||||
previews: {
|
||||
controller: 'previews',
|
||||
resource: 'previews'
|
||||
},
|
||||
email: {
|
||||
controller: 'emailPost',
|
||||
|
@ -11,8 +11,8 @@ module.exports = {
|
||||
return require('./rss');
|
||||
},
|
||||
|
||||
get preview() {
|
||||
return require('./preview');
|
||||
get previews() {
|
||||
return require('./previews');
|
||||
},
|
||||
|
||||
get email() {
|
||||
|
@ -121,8 +121,8 @@ module.exports = {
|
||||
return shared.pipeline(require('./users'), localUtils);
|
||||
},
|
||||
|
||||
get preview() {
|
||||
return shared.pipeline(require('./preview'), localUtils);
|
||||
get previews() {
|
||||
return shared.pipeline(require('./previews'), localUtils);
|
||||
},
|
||||
|
||||
get emailPost() {
|
||||
|
@ -8,7 +8,7 @@ const messages = {
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
docName: 'preview',
|
||||
docName: 'previews',
|
||||
|
||||
read: {
|
||||
permissions: true,
|
@ -85,8 +85,8 @@ module.exports = {
|
||||
return require('./users');
|
||||
},
|
||||
|
||||
get preview() {
|
||||
return require('./preview');
|
||||
get previews() {
|
||||
return require('./previews');
|
||||
},
|
||||
|
||||
get email_post() {
|
||||
|
@ -10,8 +10,8 @@ module.exports = {
|
||||
|
||||
const data = await mappers.posts(model, frame, {tiers});
|
||||
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 membersService = require('../../../../../../../core/server/services/members');
|
||||
|
||||
describe('Unit: canary/utils/serializers/output/preview', function () {
|
||||
describe('Unit: canary/utils/serializers/output/previews', function () {
|
||||
let pageModel;
|
||||
|
||||
beforeEach(function () {
|
||||
@ -46,11 +46,11 @@ describe('Unit: canary/utils/serializers/output/preview', function () {
|
||||
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.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 urlUtils = require('../../../../../../core/shared/url-utils');
|
||||
|
||||
describe('Unit - services/routing/controllers/preview', function () {
|
||||
describe('Unit - services/routing/controllers/previews', function () {
|
||||
let secureStub;
|
||||
let renderStub;
|
||||
let req;
|
||||
@ -35,7 +35,7 @@ describe('Unit - services/routing/controllers/preview', function () {
|
||||
post = testUtils.DataGenerator.forKnex.createPost({status: 'draft'});
|
||||
|
||||
apiResponse = {
|
||||
preview: [post]
|
||||
previews: [post]
|
||||
};
|
||||
|
||||
req = {
|
||||
@ -48,7 +48,7 @@ describe('Unit - services/routing/controllers/preview', function () {
|
||||
|
||||
res = {
|
||||
routerOptions: {
|
||||
query: {controller: 'preview', resource: 'preview'}
|
||||
query: {controller: 'previews', resource: 'previews'}
|
||||
},
|
||||
locals: {},
|
||||
render: sinon.spy(),
|
||||
@ -80,7 +80,7 @@ describe('Unit - services/routing/controllers/preview', function () {
|
||||
include: 'authors,tags,tiers'
|
||||
}).resolves(apiResponse);
|
||||
|
||||
sinon.stub(api, 'preview').get(() => {
|
||||
sinon.stub(api, 'previews').get(() => {
|
||||
return {
|
||||
read: previewStub
|
||||
};
|
||||
@ -88,7 +88,7 @@ describe('Unit - services/routing/controllers/preview', function () {
|
||||
});
|
||||
|
||||
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();
|
||||
secureStub.called.should.be.true();
|
||||
done();
|
Loading…
Reference in New Issue
Block a user