2018-10-10 17:34:16 +03:00
|
|
|
const should = require('should');
|
|
|
|
const supertest = require('supertest');
|
|
|
|
const _ = require('lodash');
|
|
|
|
const ObjectId = require('bson-objectid');
|
|
|
|
const moment = require('moment-timezone');
|
2019-09-20 18:02:45 +03:00
|
|
|
const testUtils = require('../../utils');
|
2020-05-27 20:47:53 +03:00
|
|
|
const config = require('../../../core/shared/config');
|
2020-03-30 18:26:47 +03:00
|
|
|
const models = require('../../../core/server/models');
|
2018-10-10 17:34:16 +03:00
|
|
|
const localUtils = require('./utils');
|
2019-09-20 18:02:45 +03:00
|
|
|
|
2018-10-10 17:34:16 +03:00
|
|
|
const ghost = testUtils.startGhost;
|
|
|
|
let request;
|
|
|
|
|
2019-02-04 17:16:24 +03:00
|
|
|
describe('Posts API', function () {
|
2019-01-23 15:22:47 +03:00
|
|
|
let ghostServer;
|
2019-02-04 17:16:24 +03:00
|
|
|
let ownerCookie;
|
|
|
|
|
|
|
|
before(function () {
|
|
|
|
return ghost()
|
|
|
|
.then(function (_ghostServer) {
|
|
|
|
ghostServer = _ghostServer;
|
|
|
|
request = supertest.agent(config.get('url'));
|
|
|
|
})
|
|
|
|
.then(function () {
|
2019-11-08 07:40:49 +03:00
|
|
|
return localUtils.doAuth(request, 'users:extra', 'posts', 'emails');
|
2019-02-04 17:16:24 +03:00
|
|
|
})
|
|
|
|
.then(function (cookie) {
|
|
|
|
ownerCookie = cookie;
|
2019-01-23 15:22:47 +03:00
|
|
|
});
|
2019-02-04 17:16:24 +03:00
|
|
|
});
|
2018-10-10 17:34:16 +03:00
|
|
|
|
2019-02-04 17:16:24 +03:00
|
|
|
it('Can retrieve all posts', function (done) {
|
|
|
|
request.get(localUtils.API.getApiQuery('posts/'))
|
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(200)
|
|
|
|
.end(function (err, res) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
should.not.exist(res.headers['x-cache-invalidate']);
|
|
|
|
const jsonResponse = res.body;
|
|
|
|
should.exist(jsonResponse.posts);
|
|
|
|
localUtils.API.checkResponse(jsonResponse, 'posts');
|
2019-02-22 06:17:14 +03:00
|
|
|
jsonResponse.posts.should.have.length(13);
|
2019-02-25 13:08:28 +03:00
|
|
|
localUtils.API.checkResponse(jsonResponse.posts[0], 'post');
|
2019-02-04 17:16:24 +03:00
|
|
|
localUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
|
|
|
|
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);
|
|
|
|
|
|
|
|
// Ensure default order
|
2019-02-22 06:17:14 +03:00
|
|
|
jsonResponse.posts[0].slug.should.eql('scheduled-post');
|
|
|
|
jsonResponse.posts[12].slug.should.eql('html-ipsum');
|
2019-02-04 17:16:24 +03:00
|
|
|
|
|
|
|
// Absolute urls by default
|
2019-03-21 21:08:38 +03:00
|
|
|
jsonResponse.posts[0].url.should.match(new RegExp(`${config.get('url')}/p/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}`));
|
2019-02-22 06:17:14 +03:00
|
|
|
jsonResponse.posts[2].url.should.eql(`${config.get('url')}/welcome/`);
|
|
|
|
jsonResponse.posts[11].feature_image.should.eql(`${config.get('url')}/content/images/2018/hey.jpg`);
|
2019-02-04 17:16:24 +03:00
|
|
|
|
2019-02-25 13:08:28 +03:00
|
|
|
jsonResponse.posts[0].tags.length.should.eql(0);
|
|
|
|
jsonResponse.posts[2].tags.length.should.eql(1);
|
|
|
|
jsonResponse.posts[2].authors.length.should.eql(1);
|
|
|
|
jsonResponse.posts[2].tags[0].url.should.eql(`${config.get('url')}/tag/getting-started/`);
|
|
|
|
jsonResponse.posts[2].authors[0].url.should.eql(`${config.get('url')}/author/ghost/`);
|
|
|
|
|
2019-02-04 17:16:24 +03:00
|
|
|
done();
|
2019-01-23 15:22:47 +03:00
|
|
|
});
|
2019-02-04 17:16:24 +03:00
|
|
|
});
|
2018-10-10 17:34:16 +03:00
|
|
|
|
2019-02-04 17:16:24 +03:00
|
|
|
it('Can retrieve multiple post formats', function (done) {
|
|
|
|
request.get(localUtils.API.getApiQuery('posts/?formats=plaintext,mobiledoc&limit=3&order=title%20ASC'))
|
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(200)
|
|
|
|
.end(function (err, res) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
should.not.exist(res.headers['x-cache-invalidate']);
|
|
|
|
const jsonResponse = res.body;
|
|
|
|
should.exist(jsonResponse.posts);
|
|
|
|
localUtils.API.checkResponse(jsonResponse, 'posts');
|
|
|
|
jsonResponse.posts.should.have.length(3);
|
2019-02-25 13:08:28 +03:00
|
|
|
localUtils.API.checkResponse(jsonResponse.posts[0], 'post', ['plaintext']);
|
2019-02-04 17:16:24 +03:00
|
|
|
localUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
|
|
|
|
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);
|
|
|
|
|
|
|
|
// ensure order works
|
|
|
|
jsonResponse.posts[0].slug.should.eql('apps-integrations');
|
|
|
|
|
|
|
|
done();
|
2019-01-23 15:22:47 +03:00
|
|
|
});
|
2019-02-04 17:16:24 +03:00
|
|
|
});
|
2018-10-10 17:34:16 +03:00
|
|
|
|
2019-11-08 07:40:49 +03:00
|
|
|
it('Can include single relation', function (done) {
|
2019-02-25 13:08:28 +03:00
|
|
|
request.get(localUtils.API.getApiQuery('posts/?include=tags'))
|
2019-02-04 17:16:24 +03:00
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(200)
|
|
|
|
.end(function (err, res) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
should.not.exist(res.headers['x-cache-invalidate']);
|
|
|
|
const jsonResponse = res.body;
|
|
|
|
should.exist(jsonResponse.posts);
|
|
|
|
localUtils.API.checkResponse(jsonResponse, 'posts');
|
2019-02-22 06:17:14 +03:00
|
|
|
jsonResponse.posts.should.have.length(13);
|
2019-02-04 17:16:24 +03:00
|
|
|
localUtils.API.checkResponse(
|
|
|
|
jsonResponse.posts[0],
|
|
|
|
'post',
|
2019-02-25 13:08:28 +03:00
|
|
|
null,
|
2019-11-08 07:40:49 +03:00
|
|
|
['authors', 'primary_author', 'email']
|
2019-02-04 17:16:24 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
localUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
|
|
|
|
done();
|
2019-01-23 15:22:47 +03:00
|
|
|
});
|
2019-02-04 17:16:24 +03:00
|
|
|
});
|
2018-10-10 17:34:16 +03:00
|
|
|
|
2019-02-04 17:16:24 +03:00
|
|
|
it('Can filter posts', function (done) {
|
2019-02-22 06:17:14 +03:00
|
|
|
request.get(localUtils.API.getApiQuery('posts/?filter=featured:true'))
|
2019-02-04 17:16:24 +03:00
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(200)
|
|
|
|
.end(function (err, res) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
should.not.exist(res.headers['x-cache-invalidate']);
|
|
|
|
const jsonResponse = res.body;
|
|
|
|
should.exist(jsonResponse.posts);
|
|
|
|
localUtils.API.checkResponse(jsonResponse, 'posts');
|
2019-02-22 06:17:14 +03:00
|
|
|
jsonResponse.posts.should.have.length(2);
|
2019-02-25 13:08:28 +03:00
|
|
|
localUtils.API.checkResponse(jsonResponse.posts[0], 'post');
|
2019-02-04 17:16:24 +03:00
|
|
|
localUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
|
|
|
|
done();
|
2019-01-23 15:22:47 +03:00
|
|
|
});
|
2019-02-04 17:16:24 +03:00
|
|
|
});
|
2018-10-10 17:34:16 +03:00
|
|
|
|
2019-02-22 06:17:14 +03:00
|
|
|
it('Cannot receive pages', function (done) {
|
|
|
|
request.get(localUtils.API.getApiQuery('posts/?filter=page:true'))
|
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(200)
|
|
|
|
.end(function (err, res) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
should.not.exist(res.headers['x-cache-invalidate']);
|
|
|
|
const jsonResponse = res.body;
|
|
|
|
should.exist(jsonResponse.posts);
|
|
|
|
localUtils.API.checkResponse(jsonResponse, 'posts');
|
|
|
|
jsonResponse.posts.should.have.length(0);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-02-04 17:16:24 +03:00
|
|
|
it('Can paginate posts', function (done) {
|
|
|
|
request.get(localUtils.API.getApiQuery('posts/?page=2'))
|
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(200)
|
|
|
|
.end(function (err, res) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
const jsonResponse = res.body;
|
|
|
|
should.equal(jsonResponse.meta.pagination.page, 2);
|
|
|
|
done();
|
2019-01-23 15:22:47 +03:00
|
|
|
});
|
2019-02-04 17:16:24 +03:00
|
|
|
});
|
2018-10-10 17:34:16 +03:00
|
|
|
|
2019-02-04 17:16:24 +03:00
|
|
|
it('Can request a post by id', function (done) {
|
|
|
|
request.get(localUtils.API.getApiQuery('posts/' + testUtils.DataGenerator.Content.posts[0].id + '/'))
|
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(200)
|
|
|
|
.end(function (err, res) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
should.not.exist(res.headers['x-cache-invalidate']);
|
2020-04-29 18:44:27 +03:00
|
|
|
const jsonResponse = res.body;
|
2019-02-04 17:16:24 +03:00
|
|
|
should.exist(jsonResponse);
|
|
|
|
should.exist(jsonResponse.posts);
|
2019-02-25 13:08:28 +03:00
|
|
|
localUtils.API.checkResponse(jsonResponse.posts[0], 'post');
|
2019-02-04 17:16:24 +03:00
|
|
|
jsonResponse.posts[0].id.should.equal(testUtils.DataGenerator.Content.posts[0].id);
|
2019-02-22 06:17:14 +03:00
|
|
|
|
2019-02-04 17:16:24 +03:00
|
|
|
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);
|
2019-02-22 06:17:14 +03:00
|
|
|
|
2019-02-04 17:16:24 +03:00
|
|
|
testUtils.API.isISO8601(jsonResponse.posts[0].created_at).should.be.true();
|
|
|
|
done();
|
2019-01-23 15:22:47 +03:00
|
|
|
});
|
2019-02-04 17:16:24 +03:00
|
|
|
});
|
2018-10-10 17:34:16 +03:00
|
|
|
|
2019-02-04 17:16:24 +03:00
|
|
|
it('Can retrieve a post by slug', function (done) {
|
|
|
|
request.get(localUtils.API.getApiQuery('posts/slug/welcome/'))
|
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(200)
|
|
|
|
.end(function (err, res) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
should.not.exist(res.headers['x-cache-invalidate']);
|
2020-04-29 18:44:27 +03:00
|
|
|
const jsonResponse = res.body;
|
2019-02-04 17:16:24 +03:00
|
|
|
should.exist(jsonResponse);
|
|
|
|
should.exist(jsonResponse.posts);
|
2019-02-25 13:08:28 +03:00
|
|
|
localUtils.API.checkResponse(jsonResponse.posts[0], 'post');
|
2019-02-04 17:16:24 +03:00
|
|
|
jsonResponse.posts[0].slug.should.equal('welcome');
|
2019-02-22 06:17:14 +03:00
|
|
|
|
2019-02-04 17:16:24 +03:00
|
|
|
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);
|
|
|
|
done();
|
2019-01-23 15:22:47 +03:00
|
|
|
});
|
2019-02-04 17:16:24 +03:00
|
|
|
});
|
2019-01-18 19:03:03 +03:00
|
|
|
|
2019-02-04 17:16:24 +03:00
|
|
|
it('Can include relations for a single post', function (done) {
|
|
|
|
request
|
2019-11-08 07:40:49 +03:00
|
|
|
.get(localUtils.API.getApiQuery('posts/' + testUtils.DataGenerator.Content.posts[0].id + '/?include=authors,tags,email'))
|
2019-02-04 17:16:24 +03:00
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(200)
|
|
|
|
.end(function (err, res) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
should.not.exist(res.headers['x-cache-invalidate']);
|
2020-04-29 18:44:27 +03:00
|
|
|
const jsonResponse = res.body;
|
2019-02-04 17:16:24 +03:00
|
|
|
should.exist(jsonResponse);
|
|
|
|
should.exist(jsonResponse.posts);
|
|
|
|
|
2019-02-25 13:08:28 +03:00
|
|
|
localUtils.API.checkResponse(jsonResponse.posts[0], 'post');
|
2019-02-04 17:16:24 +03:00
|
|
|
|
|
|
|
jsonResponse.posts[0].authors[0].should.be.an.Object();
|
2019-03-06 12:17:41 +03:00
|
|
|
localUtils.API.checkResponse(jsonResponse.posts[0].authors[0], 'user');
|
2019-02-04 17:16:24 +03:00
|
|
|
|
|
|
|
jsonResponse.posts[0].tags[0].should.be.an.Object();
|
|
|
|
localUtils.API.checkResponse(jsonResponse.posts[0].tags[0], 'tag', ['url']);
|
2019-11-08 07:40:49 +03:00
|
|
|
|
|
|
|
jsonResponse.posts[0].email.should.be.an.Object();
|
|
|
|
localUtils.API.checkResponse(jsonResponse.posts[0].email, 'email');
|
2019-02-04 17:16:24 +03:00
|
|
|
done();
|
2019-01-23 15:22:47 +03:00
|
|
|
});
|
2019-02-04 17:16:24 +03:00
|
|
|
});
|
2019-01-18 19:03:03 +03:00
|
|
|
|
2019-02-04 17:16:24 +03:00
|
|
|
it('Can add a post', function () {
|
|
|
|
const post = {
|
|
|
|
title: 'My post',
|
|
|
|
status: 'draft',
|
|
|
|
published_at: '2016-05-30T07:00:00.000Z',
|
|
|
|
mobiledoc: testUtils.DataGenerator.markdownToMobiledoc('my post'),
|
|
|
|
created_at: moment().subtract(2, 'days').toDate(),
|
|
|
|
updated_at: moment().subtract(2, 'days').toDate(),
|
|
|
|
created_by: ObjectId.generate(),
|
|
|
|
updated_by: ObjectId.generate()
|
|
|
|
};
|
|
|
|
|
|
|
|
return request.post(localUtils.API.getApiQuery('posts'))
|
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.send({posts: [post]})
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(201)
|
|
|
|
.then((res) => {
|
|
|
|
res.body.posts.length.should.eql(1);
|
2019-02-25 13:08:28 +03:00
|
|
|
localUtils.API.checkResponse(res.body.posts[0], 'post');
|
2019-03-21 21:08:38 +03:00
|
|
|
res.body.posts[0].url.should.match(new RegExp(`${config.get('url')}/p/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}`));
|
2019-02-04 17:16:24 +03:00
|
|
|
should.not.exist(res.headers['x-cache-invalidate']);
|
|
|
|
|
|
|
|
return models.Post.findOne({
|
|
|
|
id: res.body.posts[0].id,
|
2019-01-23 15:22:47 +03:00
|
|
|
status: 'draft'
|
2019-02-04 17:16:24 +03:00
|
|
|
}, testUtils.context.internal);
|
|
|
|
})
|
|
|
|
.then((model) => {
|
|
|
|
model.get('title').should.eql(post.title);
|
|
|
|
model.get('status').should.eql(post.status);
|
|
|
|
model.get('published_at').toISOString().should.eql('2016-05-30T07:00:00.000Z');
|
|
|
|
model.get('created_at').toISOString().should.not.eql(post.created_at.toISOString());
|
|
|
|
model.get('updated_at').toISOString().should.not.eql(post.updated_at.toISOString());
|
|
|
|
model.get('updated_by').should.not.eql(post.updated_by);
|
|
|
|
model.get('created_by').should.not.eql(post.created_by);
|
2019-01-23 15:22:47 +03:00
|
|
|
});
|
2019-02-04 17:16:24 +03:00
|
|
|
});
|
2019-01-18 19:03:03 +03:00
|
|
|
|
2019-02-04 17:16:24 +03:00
|
|
|
it('Can update draft', function () {
|
|
|
|
const post = {
|
|
|
|
title: 'update draft'
|
|
|
|
};
|
|
|
|
|
2019-02-21 10:39:17 +03:00
|
|
|
return request
|
2019-02-22 06:17:14 +03:00
|
|
|
.get(localUtils.API.getApiQuery(`posts/${testUtils.DataGenerator.Content.posts[3].id}/`))
|
2019-02-04 17:16:24 +03:00
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.expect(200)
|
2019-02-21 10:39:17 +03:00
|
|
|
.then((res) => {
|
|
|
|
post.updated_at = res.body.posts[0].updated_at;
|
|
|
|
|
|
|
|
return request.put(localUtils.API.getApiQuery('posts/' + testUtils.DataGenerator.Content.posts[3].id))
|
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.send({posts: [post]})
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(200);
|
|
|
|
})
|
2019-02-04 17:16:24 +03:00
|
|
|
.then((res) => {
|
|
|
|
res.headers['x-cache-invalidate'].should.eql('/p/' + res.body.posts[0].uuid + '/');
|
2018-10-10 17:34:16 +03:00
|
|
|
});
|
2019-02-04 17:16:24 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Can unpublish a post', function () {
|
|
|
|
const post = {
|
|
|
|
status: 'draft'
|
|
|
|
};
|
|
|
|
|
|
|
|
return request
|
2019-02-22 06:17:14 +03:00
|
|
|
.get(localUtils.API.getApiQuery(`posts/${testUtils.DataGenerator.Content.posts[1].id}/?`))
|
2019-02-04 17:16:24 +03:00
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.expect(200)
|
2019-02-21 10:39:17 +03:00
|
|
|
.then((res) => {
|
|
|
|
post.updated_at = res.body.posts[0].updated_at;
|
|
|
|
|
|
|
|
return request
|
|
|
|
.put(localUtils.API.getApiQuery('posts/' + testUtils.DataGenerator.Content.posts[1].id + '/'))
|
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.send({posts: [post]})
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(200);
|
|
|
|
})
|
2019-02-04 17:16:24 +03:00
|
|
|
.then((res) => {
|
|
|
|
res.headers['x-cache-invalidate'].should.eql('/*');
|
|
|
|
res.body.posts[0].status.should.eql('draft');
|
2019-01-23 15:22:47 +03:00
|
|
|
});
|
2019-02-04 17:16:24 +03:00
|
|
|
});
|
2019-01-18 19:03:03 +03:00
|
|
|
|
2019-02-04 17:16:24 +03:00
|
|
|
it('Can destroy a post', function () {
|
|
|
|
return request
|
|
|
|
.del(localUtils.API.getApiQuery('posts/' + testUtils.DataGenerator.Content.posts[0].id + '/'))
|
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(204)
|
|
|
|
.then((res) => {
|
|
|
|
res.body.should.be.empty();
|
|
|
|
res.headers['x-cache-invalidate'].should.eql('/*');
|
2018-10-10 17:34:16 +03:00
|
|
|
});
|
|
|
|
});
|
2019-02-22 06:17:14 +03:00
|
|
|
|
|
|
|
it('Cannot get post via pages endpoint', function () {
|
|
|
|
return request.get(localUtils.API.getApiQuery(`pages/${testUtils.DataGenerator.Content.posts[3].id}/`))
|
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(404);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Cannot update post via pages endpoint', function () {
|
|
|
|
const post = {
|
|
|
|
title: 'fails',
|
|
|
|
updated_at: new Date().toISOString()
|
|
|
|
};
|
|
|
|
|
|
|
|
return request.put(localUtils.API.getApiQuery('pages/' + testUtils.DataGenerator.Content.posts[3].id))
|
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.send({pages: [post]})
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(404);
|
|
|
|
});
|
2018-10-10 17:34:16 +03:00
|
|
|
});
|