mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 01:42:29 +03:00
Fixed "no-shadow" eslint warning in tests
refs b6728ecb0f
- The "no-shadow" eslint rune was introduced into ghost's eslint plugin (referenced commmit), which resulted in flood of warning in console output when linting the project codebase.
- This cleanup is aiming to make any new linting issues more visible. Follow up commits will contain similar cleanups in other parts of the codebase
This commit is contained in:
parent
b61fb2a867
commit
143921948d
@ -135,8 +135,8 @@ describe('Integrations API', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Can successfully get a created integration', function (done) {
|
it('Can successfully get a created integration', function () {
|
||||||
request.post(localUtils.API.getApiQuery('integrations/'))
|
return request.post(localUtils.API.getApiQuery('integrations/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send({
|
.send({
|
||||||
integrations: [{
|
integrations: [{
|
||||||
@ -144,22 +144,18 @@ describe('Integrations API', function () {
|
|||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
.expect(201)
|
.expect(201)
|
||||||
.end(function (err, {body}) {
|
.then(function ({body}) {
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
const [createdIntegration] = body.integrations;
|
const [createdIntegration] = body.integrations;
|
||||||
|
|
||||||
request.get(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
|
return createdIntegration;
|
||||||
|
})
|
||||||
|
.then((createdIntegration) => {
|
||||||
|
return request.get(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function (err, {body}) {
|
.then(function ({body}) {
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
should.equal(body.integrations.length, 1);
|
should.equal(body.integrations.length, 1);
|
||||||
|
|
||||||
const [integration] = body.integrations;
|
const [integration] = body.integrations;
|
||||||
@ -169,13 +165,12 @@ describe('Integrations API', function () {
|
|||||||
should.equal(integration.slug, createdIntegration.slug);
|
should.equal(integration.slug, createdIntegration.slug);
|
||||||
should.equal(integration.description, createdIntegration.description);
|
should.equal(integration.description, createdIntegration.description);
|
||||||
should.equal(integration.icon_image, createdIntegration.icon_image);
|
should.equal(integration.icon_image, createdIntegration.icon_image);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Can successfully get *all* created integrations with api_keys', function (done) {
|
it('Can successfully get *all* created integrations with api_keys', function () {
|
||||||
request.post(localUtils.API.getApiQuery('integrations/'))
|
return request.post(localUtils.API.getApiQuery('integrations/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send({
|
.send({
|
||||||
integrations: [{
|
integrations: [{
|
||||||
@ -183,51 +178,40 @@ describe('Integrations API', function () {
|
|||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
.expect(201)
|
.expect(201)
|
||||||
.end(function (err) {
|
.then(function () {
|
||||||
if (err) {
|
return request.post(localUtils.API.getApiQuery('integrations/'))
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
request.post(localUtils.API.getApiQuery('integrations/'))
|
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send({
|
.send({
|
||||||
integrations: [{
|
integrations: [{
|
||||||
name: 'Winter-(is)-great'
|
name: 'Winter-(is)-great'
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
.expect(201)
|
.expect(201);
|
||||||
.end(function (err) {
|
})
|
||||||
if (err) {
|
.then(function () {
|
||||||
return done(err);
|
return request.get(localUtils.API.getApiQuery(`integrations/?include=api_keys&limit=all`))
|
||||||
}
|
.set('Origin', config.get('url'))
|
||||||
|
.expect('Content-Type', /json/)
|
||||||
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
|
.expect(200)
|
||||||
|
.then(function ({body}) {
|
||||||
|
// This is the only page
|
||||||
|
should.equal(body.meta.pagination.page, 1);
|
||||||
|
should.equal(body.meta.pagination.pages, 1);
|
||||||
|
should.equal(body.meta.pagination.next, null);
|
||||||
|
should.equal(body.meta.pagination.prev, null);
|
||||||
|
|
||||||
request.get(localUtils.API.getApiQuery(`integrations/?include=api_keys&limit=all`))
|
body.integrations.forEach((integration) => {
|
||||||
.set('Origin', config.get('url'))
|
should.exist(integration.api_keys);
|
||||||
.expect('Content-Type', /json/)
|
});
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
||||||
.expect(200)
|
|
||||||
.end(function (err, {body}) {
|
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is the only page
|
|
||||||
should.equal(body.meta.pagination.page, 1);
|
|
||||||
should.equal(body.meta.pagination.pages, 1);
|
|
||||||
should.equal(body.meta.pagination.next, null);
|
|
||||||
should.equal(body.meta.pagination.prev, null);
|
|
||||||
|
|
||||||
body.integrations.forEach((integration) => {
|
|
||||||
should.exist(integration.api_keys);
|
|
||||||
});
|
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Can successfully edit a created integration', function (done) {
|
it('Can successfully edit a created integration', function () {
|
||||||
request.post(localUtils.API.getApiQuery('integrations/'))
|
let createdIntegration;
|
||||||
|
|
||||||
|
return request.post(localUtils.API.getApiQuery('integrations/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send({
|
.send({
|
||||||
integrations: [{
|
integrations: [{
|
||||||
@ -235,12 +219,10 @@ describe('Integrations API', function () {
|
|||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
.expect(201)
|
.expect(201)
|
||||||
.end(function (err, {body}) {
|
.then(function ({body}) {
|
||||||
if (err) {
|
[createdIntegration] = body.integrations;
|
||||||
return done(err);
|
|
||||||
}
|
return request.put(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
|
||||||
const [createdIntegration] = body.integrations;
|
|
||||||
request.put(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
|
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send({
|
.send({
|
||||||
integrations: [{
|
integrations: [{
|
||||||
@ -248,35 +230,30 @@ describe('Integrations API', function () {
|
|||||||
description: 'Finally got round to writing this...'
|
description: 'Finally got round to writing this...'
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
.expect(200)
|
.expect(200);
|
||||||
.end(function (err) {
|
})
|
||||||
if (err) {
|
.then(function () {
|
||||||
return done(err);
|
return request.get(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
|
||||||
}
|
.set('Origin', config.get('url'))
|
||||||
|
.expect('Content-Type', /json/)
|
||||||
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
|
.expect(200);
|
||||||
|
})
|
||||||
|
.then(function ({body}) {
|
||||||
|
const [updatedIntegration] = body.integrations;
|
||||||
|
|
||||||
request.get(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
|
should.equal(updatedIntegration.id, createdIntegration.id);
|
||||||
.set('Origin', config.get('url'))
|
should.equal(updatedIntegration.name, 'Awesome Integration Name');
|
||||||
.expect('Content-Type', /json/)
|
should.equal(updatedIntegration.description, 'Finally got round to writing this...');
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
||||||
.expect(200)
|
|
||||||
.end(function (err, {body}) {
|
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
const [updatedIntegration] = body.integrations;
|
|
||||||
|
|
||||||
should.equal(updatedIntegration.id, createdIntegration.id);
|
|
||||||
should.equal(updatedIntegration.name, 'Awesome Integration Name');
|
|
||||||
should.equal(updatedIntegration.description, 'Finally got round to writing this...');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Can successfully refresh an integration api key', function (done) {
|
it('Can successfully refresh an integration api key', function () {
|
||||||
request.post(localUtils.API.getApiQuery('integrations/?include=api_keys'))
|
let createdIntegration;
|
||||||
|
let apiKeys;
|
||||||
|
let adminApiKey;
|
||||||
|
|
||||||
|
return request.post(localUtils.API.getApiQuery('integrations/?include=api_keys'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send({
|
.send({
|
||||||
integrations: [{
|
integrations: [{
|
||||||
@ -284,60 +261,53 @@ describe('Integrations API', function () {
|
|||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
.expect(201)
|
.expect(201)
|
||||||
.end(function (err, {body}) {
|
.then(function ({body}) {
|
||||||
if (err) {
|
[createdIntegration] = body.integrations;
|
||||||
return done(err);
|
apiKeys = createdIntegration.api_keys;
|
||||||
}
|
adminApiKey = apiKeys.find(key => key.type === 'admin');
|
||||||
const [createdIntegration] = body.integrations;
|
|
||||||
const apiKeys = createdIntegration.api_keys;
|
return request.post(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/api_key/${adminApiKey.id}/refresh`))
|
||||||
const adminApiKey = apiKeys.find(key => key.type === 'admin');
|
|
||||||
request.post(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/api_key/${adminApiKey.id}/refresh`))
|
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send({
|
.send({
|
||||||
integrations: [{
|
integrations: [{
|
||||||
id: createdIntegration.id
|
id: createdIntegration.id
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
|
.expect(200);
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
return request.get(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/?include=api_keys`))
|
||||||
|
.set('Origin', config.get('url'))
|
||||||
|
.expect('Content-Type', /json/)
|
||||||
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
|
.expect(200);
|
||||||
|
})
|
||||||
|
.then(function ({body}) {
|
||||||
|
const [updatedIntegration] = body.integrations;
|
||||||
|
const updatedAdminApiKey = updatedIntegration.api_keys.find(key => key.type === 'admin');
|
||||||
|
should.equal(updatedIntegration.id, createdIntegration.id);
|
||||||
|
updatedAdminApiKey.secret.should.not.eql(adminApiKey.secret);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return request.get(localUtils.API.getApiQuery(`actions/?filter=resource_id:${adminApiKey.id}&include=actor`))
|
||||||
|
.set('Origin', config.get('url'))
|
||||||
|
.expect('Content-Type', /json/)
|
||||||
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function (err) {
|
.then(function ({body}) {
|
||||||
if (err) {
|
const actions = body.actions;
|
||||||
return done(err);
|
const refreshedAction = actions.find((action) => {
|
||||||
}
|
return action.event === 'refreshed';
|
||||||
|
});
|
||||||
request.get(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/?include=api_keys`))
|
should.exist(refreshedAction);
|
||||||
.set('Origin', config.get('url'))
|
|
||||||
.expect('Content-Type', /json/)
|
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
||||||
.expect(200)
|
|
||||||
.end(function (err, {body}) {
|
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
const [updatedIntegration] = body.integrations;
|
|
||||||
const updatedAdminApiKey = updatedIntegration.api_keys.find(key => key.type === 'admin');
|
|
||||||
should.equal(updatedIntegration.id, createdIntegration.id);
|
|
||||||
updatedAdminApiKey.secret.should.not.eql(adminApiKey.secret);
|
|
||||||
request.get(localUtils.API.getApiQuery(`actions/?filter=resource_id:${adminApiKey.id}&include=actor`))
|
|
||||||
.set('Origin', config.get('url'))
|
|
||||||
.expect('Content-Type', /json/)
|
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
||||||
.expect(200)
|
|
||||||
.end(function (err, {body}) {
|
|
||||||
const actions = body.actions;
|
|
||||||
const refreshedAction = actions.find((action) => {
|
|
||||||
return action.event === 'refreshed';
|
|
||||||
});
|
|
||||||
should.exist(refreshedAction);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Can successfully add and delete a created integrations webhooks', function (done) {
|
it('Can successfully add and delete a created integrations webhooks', function () {
|
||||||
request.post(localUtils.API.getApiQuery('integrations/'))
|
let createdIntegration;
|
||||||
|
|
||||||
|
return request.post(localUtils.API.getApiQuery('integrations/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send({
|
.send({
|
||||||
integrations: [{
|
integrations: [{
|
||||||
@ -345,12 +315,10 @@ describe('Integrations API', function () {
|
|||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
.expect(201)
|
.expect(201)
|
||||||
.end(function (err, {body}) {
|
.then(function ({body}) {
|
||||||
if (err) {
|
[createdIntegration] = body.integrations;
|
||||||
return done(err);
|
|
||||||
}
|
return request.put(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
|
||||||
const [createdIntegration] = body.integrations;
|
|
||||||
request.put(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
|
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send({
|
.send({
|
||||||
integrations: [{
|
integrations: [{
|
||||||
@ -360,65 +328,48 @@ describe('Integrations API', function () {
|
|||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
|
.expect(200);
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
return request.get(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/?include=webhooks`))
|
||||||
|
.set('Origin', config.get('url'))
|
||||||
|
.expect('Content-Type', /json/)
|
||||||
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
|
.expect(200);
|
||||||
|
})
|
||||||
|
.then(function ({body}) {
|
||||||
|
const [updatedIntegration] = body.integrations;
|
||||||
|
|
||||||
|
should.equal(updatedIntegration.webhooks.length, 1);
|
||||||
|
|
||||||
|
const webhook = updatedIntegration.webhooks[0];
|
||||||
|
should.equal(webhook.integration_id, updatedIntegration.id);
|
||||||
|
|
||||||
|
return request.put(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
|
||||||
|
.set('Origin', config.get('url'))
|
||||||
|
.send({
|
||||||
|
integrations: [{
|
||||||
|
webhooks: []
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
.expect(200);
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
return request.get(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/?include=webhooks`))
|
||||||
|
.set('Origin', config.get('url'))
|
||||||
|
.expect('Content-Type', /json/)
|
||||||
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function (err) {
|
.then(function ({body}) {
|
||||||
if (err) {
|
const [updatedIntegration] = body.integrations;
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
request.get(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/?include=webhooks`))
|
should.equal(updatedIntegration.webhooks.length, 0);
|
||||||
.set('Origin', config.get('url'))
|
|
||||||
.expect('Content-Type', /json/)
|
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
||||||
.expect(200)
|
|
||||||
.end(function (err, {body}) {
|
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
const [updatedIntegration] = body.integrations;
|
|
||||||
|
|
||||||
should.equal(updatedIntegration.webhooks.length, 1);
|
|
||||||
|
|
||||||
const webhook = updatedIntegration.webhooks[0];
|
|
||||||
should.equal(webhook.integration_id, updatedIntegration.id);
|
|
||||||
|
|
||||||
request.put(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
|
|
||||||
.set('Origin', config.get('url'))
|
|
||||||
.send({
|
|
||||||
integrations: [{
|
|
||||||
webhooks: []
|
|
||||||
}]
|
|
||||||
})
|
|
||||||
.expect(200)
|
|
||||||
.end(function (err) {
|
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
request.get(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/?include=webhooks`))
|
|
||||||
.set('Origin', config.get('url'))
|
|
||||||
.expect('Content-Type', /json/)
|
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
||||||
.expect(200)
|
|
||||||
.end(function (err, {body}) {
|
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
const [updatedIntegration] = body.integrations;
|
|
||||||
|
|
||||||
should.equal(updatedIntegration.webhooks.length, 0);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Can succesfully delete a created integration', function (done) {
|
it('Can succesfully delete a created integration', function () {
|
||||||
request.post(localUtils.API.getApiQuery('integrations/'))
|
return request.post(localUtils.API.getApiQuery('integrations/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send({
|
.send({
|
||||||
integrations: [{
|
integrations: [{
|
||||||
@ -426,24 +377,16 @@ describe('Integrations API', function () {
|
|||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
.expect(201)
|
.expect(201)
|
||||||
.end(function (err, {body}) {
|
.then(function ({body}) {
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
const [createdIntegration] = body.integrations;
|
const [createdIntegration] = body.integrations;
|
||||||
|
|
||||||
request.del(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
|
return request.del(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.expect(204)
|
.expect(204)
|
||||||
.end(function (err) {
|
.then(function () {
|
||||||
if (err) {
|
return request.get(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
request.get(localUtils.API.getApiQuery(`integrations/${createdIntegration.id}/`))
|
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.expect(404)
|
.expect(404);
|
||||||
.end(done);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -87,16 +87,12 @@ describe('Settings API', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Can edit a setting', function (done) {
|
it('Can edit a setting', function () {
|
||||||
request.get(localUtils.API.getApiQuery('settings/'))
|
return request.get(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.end(function (err, res) {
|
.then(function (res) {
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
const jsonResponse = res.body;
|
const jsonResponse = res.body;
|
||||||
const changedValue = [];
|
const changedValue = [];
|
||||||
|
|
||||||
@ -172,19 +168,15 @@ describe('Settings API', function () {
|
|||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
should.exist(jsonResponse.settings);
|
should.exist(jsonResponse.settings);
|
||||||
|
|
||||||
request.put(localUtils.API.getApiQuery('settings/'))
|
return request.put(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send(settingToChange)
|
.send(settingToChange)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function (err, res) {
|
.then(function ({body, headers}) {
|
||||||
if (err) {
|
const putBody = body;
|
||||||
return done(err);
|
headers['x-cache-invalidate'].should.eql('/*');
|
||||||
}
|
|
||||||
|
|
||||||
const putBody = res.body;
|
|
||||||
res.headers['x-cache-invalidate'].should.eql('/*');
|
|
||||||
should.exist(putBody);
|
should.exist(putBody);
|
||||||
|
|
||||||
putBody.settings[0].key.should.eql('title');
|
putBody.settings[0].key.should.eql('title');
|
||||||
@ -239,7 +231,6 @@ describe('Settings API', function () {
|
|||||||
should.equal(putBody.settings[15].value, 'Pacific/Auckland');
|
should.equal(putBody.settings[15].value, 'Pacific/Auckland');
|
||||||
|
|
||||||
localUtils.API.checkResponse(putBody, 'settings');
|
localUtils.API.checkResponse(putBody, 'settings');
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -200,8 +200,8 @@ describe('User API', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can edit a user', function (done) {
|
it('can edit a user', function () {
|
||||||
request.put(localUtils.API.getApiQuery('users/me/'))
|
return request.put(localUtils.API.getApiQuery('users/me/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send({
|
.send({
|
||||||
users: [{
|
users: [{
|
||||||
@ -212,11 +212,7 @@ describe('User API', function () {
|
|||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function (err, res) {
|
.then(function (res) {
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
const putBody = res.body;
|
const putBody = res.body;
|
||||||
res.headers['x-cache-invalidate'].should.eql('/*');
|
res.headers['x-cache-invalidate'].should.eql('/*');
|
||||||
should.exist(putBody.users[0]);
|
should.exist(putBody.users[0]);
|
||||||
@ -226,7 +222,7 @@ describe('User API', function () {
|
|||||||
|
|
||||||
should.not.exist(putBody.users[0].password);
|
should.not.exist(putBody.users[0].password);
|
||||||
|
|
||||||
models.User.findOne({id: putBody.users[0].id})
|
return models.User.findOne({id: putBody.users[0].id})
|
||||||
.then((user) => {
|
.then((user) => {
|
||||||
return models.User.isPasswordCorrect({
|
return models.User.isPasswordCorrect({
|
||||||
plainPassword: 'mynewfancypasswordwhichisnotallowed',
|
plainPassword: 'mynewfancypasswordwhichisnotallowed',
|
||||||
@ -236,7 +232,6 @@ describe('User API', function () {
|
|||||||
.then(Promise.reject)
|
.then(Promise.reject)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
err.code.should.eql('PASSWORD_INCORRECT');
|
err.code.should.eql('PASSWORD_INCORRECT');
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -285,14 +280,14 @@ describe('User API', function () {
|
|||||||
})
|
})
|
||||||
.select();
|
.select();
|
||||||
})
|
})
|
||||||
.then((models) => {
|
.then((rolesUsersModels) => {
|
||||||
models.length.should.eql(0);
|
rolesUsersModels.length.should.eql(0);
|
||||||
|
|
||||||
return db.knex('roles_users')
|
return db.knex('roles_users')
|
||||||
.select();
|
.select();
|
||||||
})
|
})
|
||||||
.then((models) => {
|
.then((rolesUsers) => {
|
||||||
models.length.should.greaterThan(0);
|
rolesUsers.length.should.greaterThan(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -86,14 +86,14 @@ describe('Settings Content API', function () {
|
|||||||
// Object.keys(settings).length.should.equal(22);
|
// Object.keys(settings).length.should.equal(22);
|
||||||
Object.keys(settings).should.deepEqual(defaultSettingsKeys);
|
Object.keys(settings).should.deepEqual(defaultSettingsKeys);
|
||||||
// Verify that we are returning the defaults for each value
|
// Verify that we are returning the defaults for each value
|
||||||
_.forEach(settings, (value, key) => {
|
_.forEach(settings, (value, settingsKey) => {
|
||||||
// `url` does not come from the settings cache
|
// `url` does not come from the settings cache
|
||||||
if (key === 'url') {
|
if (settingsKey === 'url') {
|
||||||
should(value).eql(`${config.get('url')}/`);
|
should(value).eql(`${config.get('url')}/`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let defaultKey = _.findKey(publicSettings, v => v === key);
|
let defaultKey = _.findKey(publicSettings, v => v === settingsKey);
|
||||||
let defaultValue = _.find(flattenedPublicSettings, setting => setting.key === defaultKey).defaultValue;
|
let defaultValue = _.find(flattenedPublicSettings, setting => setting.key === defaultKey).defaultValue;
|
||||||
|
|
||||||
// Convert empty strings to null
|
// Convert empty strings to null
|
||||||
|
@ -12,7 +12,6 @@ let request;
|
|||||||
|
|
||||||
const verifyJWKS = (endpoint, token) => {
|
const verifyJWKS = (endpoint, token) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const jwksClient = require('jwks-rsa');
|
|
||||||
const client = jwksClient({
|
const client = jwksClient({
|
||||||
jwksUri: endpoint
|
jwksUri: endpoint
|
||||||
});
|
});
|
||||||
|
@ -399,18 +399,13 @@ describe('Settings API (canary)', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can toggle member setting', function (done) {
|
it('can toggle member setting', function () {
|
||||||
request.get(localUtils.API.getApiQuery('settings/'))
|
return request.get(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.end(function (err, res) {
|
.then(function (res) {
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
const jsonResponse = res.body;
|
const jsonResponse = res.body;
|
||||||
const changedValue = [];
|
|
||||||
|
|
||||||
const settingToChange = {
|
const settingToChange = {
|
||||||
settings: [
|
settings: [
|
||||||
@ -424,25 +419,19 @@ describe('Settings API (canary)', function () {
|
|||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
should.exist(jsonResponse.settings);
|
should.exist(jsonResponse.settings);
|
||||||
|
|
||||||
request.put(localUtils.API.getApiQuery('settings/'))
|
return request.put(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send(settingToChange)
|
.send(settingToChange)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function (err, res) {
|
.then(function ({body, headers}) {
|
||||||
if (err) {
|
const putBody = body;
|
||||||
return done(err);
|
headers['x-cache-invalidate'].should.eql('/*');
|
||||||
}
|
|
||||||
|
|
||||||
const putBody = res.body;
|
|
||||||
res.headers['x-cache-invalidate'].should.eql('/*');
|
|
||||||
should.exist(putBody);
|
should.exist(putBody);
|
||||||
|
|
||||||
putBody.settings[0].key.should.eql('labs');
|
putBody.settings[0].key.should.eql('labs');
|
||||||
putBody.settings[0].value.should.eql(JSON.stringify({subscribers: false, members: false}));
|
putBody.settings[0].value.should.eql(JSON.stringify({subscribers: false, members: false}));
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -507,16 +496,12 @@ describe('Settings API (canary)', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Will transform "1"', function (done) {
|
it('Will transform "1"', function () {
|
||||||
request.get(localUtils.API.getApiQuery('settings/'))
|
return request.get(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.end(function (err, res) {
|
.then(function (res) {
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
const jsonResponse = res.body;
|
const jsonResponse = res.body;
|
||||||
|
|
||||||
const settingToChange = {
|
const settingToChange = {
|
||||||
@ -531,26 +516,21 @@ describe('Settings API (canary)', function () {
|
|||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
should.exist(jsonResponse.settings);
|
should.exist(jsonResponse.settings);
|
||||||
|
|
||||||
request.put(localUtils.API.getApiQuery('settings/'))
|
return request.put(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send(settingToChange)
|
.send(settingToChange)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function (err, res) {
|
.then(function ({body, headers}) {
|
||||||
if (err) {
|
const putBody = body;
|
||||||
return done(err);
|
headers['x-cache-invalidate'].should.eql('/*');
|
||||||
}
|
|
||||||
|
|
||||||
const putBody = res.body;
|
|
||||||
res.headers['x-cache-invalidate'].should.eql('/*');
|
|
||||||
should.exist(putBody);
|
should.exist(putBody);
|
||||||
|
|
||||||
putBody.settings[0].key.should.eql('is_private');
|
putBody.settings[0].key.should.eql('is_private');
|
||||||
putBody.settings[0].value.should.eql(true);
|
putBody.settings[0].value.should.eql(true);
|
||||||
|
|
||||||
localUtils.API.checkResponse(putBody, 'settings');
|
localUtils.API.checkResponse(putBody, 'settings');
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -629,36 +609,28 @@ describe('Settings API (canary)', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not be able to edit settings', function (done) {
|
it('should not be able to edit settings', function () {
|
||||||
request.get(localUtils.API.getApiQuery('settings/'))
|
return request.get(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.end(function (err, res) {
|
.then(function (res) {
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
let jsonResponse = res.body;
|
let jsonResponse = res.body;
|
||||||
const newValue = 'new value';
|
const newValue = 'new value';
|
||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
should.exist(jsonResponse.settings);
|
should.exist(jsonResponse.settings);
|
||||||
jsonResponse.settings = [{key: 'visibility', value: 'public'}];
|
jsonResponse.settings = [{key: 'visibility', value: 'public'}];
|
||||||
|
|
||||||
request.put(localUtils.API.getApiQuery('settings/'))
|
return request.put(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send(jsonResponse)
|
.send(jsonResponse)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(403)
|
.expect(403)
|
||||||
.end(function (err, res) {
|
.then(function ({body, headers}) {
|
||||||
if (err) {
|
jsonResponse = body;
|
||||||
return done(err);
|
should.not.exist(headers['x-cache-invalidate']);
|
||||||
}
|
|
||||||
|
|
||||||
jsonResponse = res.body;
|
|
||||||
should.not.exist(res.headers['x-cache-invalidate']);
|
|
||||||
should.exist(jsonResponse.errors);
|
should.exist(jsonResponse.errors);
|
||||||
testUtils.API.checkResponseValue(jsonResponse.errors[0], [
|
testUtils.API.checkResponseValue(jsonResponse.errors[0], [
|
||||||
'message',
|
'message',
|
||||||
@ -670,8 +642,6 @@ describe('Settings API (canary)', function () {
|
|||||||
'code',
|
'code',
|
||||||
'id'
|
'id'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -699,36 +669,27 @@ describe('Settings API (canary)', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not be able to edit settings', function (done) {
|
it('should not be able to edit settings', function () {
|
||||||
request.get(localUtils.API.getApiQuery('settings/'))
|
return request.get(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.end(function (err, res) {
|
.then(function (res) {
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
let jsonResponse = res.body;
|
let jsonResponse = res.body;
|
||||||
const newValue = 'new value';
|
|
||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
should.exist(jsonResponse.settings);
|
should.exist(jsonResponse.settings);
|
||||||
jsonResponse.settings = [{key: 'visibility', value: 'public'}];
|
jsonResponse.settings = [{key: 'visibility', value: 'public'}];
|
||||||
|
|
||||||
request.put(localUtils.API.getApiQuery('settings/'))
|
return request.put(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send(jsonResponse)
|
.send(jsonResponse)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(403)
|
.expect(403)
|
||||||
.end(function (err, res) {
|
.then(function ({body, headers}) {
|
||||||
if (err) {
|
jsonResponse = body;
|
||||||
return done(err);
|
should.not.exist(headers['x-cache-invalidate']);
|
||||||
}
|
|
||||||
|
|
||||||
jsonResponse = res.body;
|
|
||||||
should.not.exist(res.headers['x-cache-invalidate']);
|
|
||||||
should.exist(jsonResponse.errors);
|
should.exist(jsonResponse.errors);
|
||||||
testUtils.API.checkResponseValue(jsonResponse.errors[0], [
|
testUtils.API.checkResponseValue(jsonResponse.errors[0], [
|
||||||
'message',
|
'message',
|
||||||
@ -740,8 +701,6 @@ describe('Settings API (canary)', function () {
|
|||||||
'code',
|
'code',
|
||||||
'id'
|
'id'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -359,16 +359,12 @@ describe('Settings API (v2)', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can toggle member setting', function (done) {
|
it('can toggle member setting', function () {
|
||||||
request.get(localUtils.API.getApiQuery('settings/'))
|
return request.get(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.end(function (err, res) {
|
.then(function (res) {
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
const jsonResponse = res.body;
|
const jsonResponse = res.body;
|
||||||
const changedValue = [];
|
const changedValue = [];
|
||||||
|
|
||||||
@ -384,25 +380,19 @@ describe('Settings API (v2)', function () {
|
|||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
should.exist(jsonResponse.settings);
|
should.exist(jsonResponse.settings);
|
||||||
|
|
||||||
request.put(localUtils.API.getApiQuery('settings/'))
|
return request.put(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send(settingToChange)
|
.send(settingToChange)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function (err, res) {
|
.then(function ({body, headers}) {
|
||||||
if (err) {
|
const putBody = body;
|
||||||
return done(err);
|
headers['x-cache-invalidate'].should.eql('/*');
|
||||||
}
|
|
||||||
|
|
||||||
const putBody = res.body;
|
|
||||||
res.headers['x-cache-invalidate'].should.eql('/*');
|
|
||||||
should.exist(putBody);
|
should.exist(putBody);
|
||||||
|
|
||||||
putBody.settings[0].key.should.eql('labs');
|
putBody.settings[0].key.should.eql('labs');
|
||||||
putBody.settings[0].value.should.eql(JSON.stringify({subscribers: false, members: false}));
|
putBody.settings[0].value.should.eql(JSON.stringify({subscribers: false, members: false}));
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -427,36 +417,28 @@ describe('Settings API (v2)', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can\'t edit non existent setting', function (done) {
|
it('can\'t edit non existent setting', function () {
|
||||||
request.get(localUtils.API.getApiQuery('settings/'))
|
return request.get(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.end(function (err, res) {
|
.then(function (res) {
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
let jsonResponse = res.body;
|
let jsonResponse = res.body;
|
||||||
const newValue = 'new value';
|
const newValue = 'new value';
|
||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
should.exist(jsonResponse.settings);
|
should.exist(jsonResponse.settings);
|
||||||
jsonResponse.settings = [{key: 'testvalue', value: newValue}];
|
jsonResponse.settings = [{key: 'testvalue', value: newValue}];
|
||||||
|
|
||||||
request.put(localUtils.API.getApiQuery('settings/'))
|
return request.put(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send(jsonResponse)
|
.send(jsonResponse)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(404)
|
.expect(404)
|
||||||
.end(function (err, res) {
|
.then(function ({body, headers}) {
|
||||||
if (err) {
|
jsonResponse = body;
|
||||||
return done(err);
|
should.not.exist(headers['x-cache-invalidate']);
|
||||||
}
|
|
||||||
|
|
||||||
jsonResponse = res.body;
|
|
||||||
should.not.exist(res.headers['x-cache-invalidate']);
|
|
||||||
should.exist(jsonResponse.errors);
|
should.exist(jsonResponse.errors);
|
||||||
testUtils.API.checkResponseValue(jsonResponse.errors[0], [
|
testUtils.API.checkResponseValue(jsonResponse.errors[0], [
|
||||||
'message',
|
'message',
|
||||||
@ -468,21 +450,16 @@ describe('Settings API (v2)', function () {
|
|||||||
'code',
|
'code',
|
||||||
'id'
|
'id'
|
||||||
]);
|
]);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Will transform "1"', function (done) {
|
it('Will transform "1"', function () {
|
||||||
request.get(localUtils.API.getApiQuery('settings/'))
|
return request.get(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.end(function (err, res) {
|
.then(function (res) {
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
const jsonResponse = res.body;
|
const jsonResponse = res.body;
|
||||||
|
|
||||||
const settingToChange = {
|
const settingToChange = {
|
||||||
@ -503,20 +480,15 @@ describe('Settings API (v2)', function () {
|
|||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function (err, res) {
|
.then(function ({body, headers}) {
|
||||||
if (err) {
|
const putBody = body;
|
||||||
return done(err);
|
headers['x-cache-invalidate'].should.eql('/*');
|
||||||
}
|
|
||||||
|
|
||||||
const putBody = res.body;
|
|
||||||
res.headers['x-cache-invalidate'].should.eql('/*');
|
|
||||||
should.exist(putBody);
|
should.exist(putBody);
|
||||||
|
|
||||||
putBody.settings[0].key.should.eql('is_private');
|
putBody.settings[0].key.should.eql('is_private');
|
||||||
putBody.settings[0].value.should.eql(true);
|
putBody.settings[0].value.should.eql(true);
|
||||||
|
|
||||||
localUtils.API.checkResponse(putBody, 'settings');
|
localUtils.API.checkResponse(putBody, 'settings');
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -595,36 +567,28 @@ describe('Settings API (v2)', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not be able to edit settings', function (done) {
|
it('should not be able to edit settings', function () {
|
||||||
request.get(localUtils.API.getApiQuery('settings/'))
|
return request.get(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.end(function (err, res) {
|
.then(function (res) {
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
let jsonResponse = res.body;
|
let jsonResponse = res.body;
|
||||||
const newValue = 'new value';
|
|
||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
should.exist(jsonResponse.settings);
|
should.exist(jsonResponse.settings);
|
||||||
jsonResponse.settings = [{key: 'visibility', value: 'public'}];
|
jsonResponse.settings = [{key: 'visibility', value: 'public'}];
|
||||||
|
|
||||||
request.put(localUtils.API.getApiQuery('settings/'))
|
return request.put(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send(jsonResponse)
|
.send(jsonResponse)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(403)
|
.expect(403)
|
||||||
.end(function (err, res) {
|
.then(function ({body, headers}) {
|
||||||
if (err) {
|
jsonResponse = body;
|
||||||
return done(err);
|
should.not.exist(headers['x-cache-invalidate']);
|
||||||
}
|
|
||||||
|
|
||||||
jsonResponse = res.body;
|
|
||||||
should.not.exist(res.headers['x-cache-invalidate']);
|
|
||||||
should.exist(jsonResponse.errors);
|
should.exist(jsonResponse.errors);
|
||||||
testUtils.API.checkResponseValue(jsonResponse.errors[0], [
|
testUtils.API.checkResponseValue(jsonResponse.errors[0], [
|
||||||
'message',
|
'message',
|
||||||
@ -636,8 +600,6 @@ describe('Settings API (v2)', function () {
|
|||||||
'code',
|
'code',
|
||||||
'id'
|
'id'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -665,36 +627,27 @@ describe('Settings API (v2)', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not be able to edit settings', function (done) {
|
it('should not be able to edit settings', function () {
|
||||||
request.get(localUtils.API.getApiQuery('settings/'))
|
return request.get(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.end(function (err, res) {
|
.then(function (res) {
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
let jsonResponse = res.body;
|
let jsonResponse = res.body;
|
||||||
const newValue = 'new value';
|
|
||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
should.exist(jsonResponse.settings);
|
should.exist(jsonResponse.settings);
|
||||||
jsonResponse.settings = [{key: 'visibility', value: 'public'}];
|
jsonResponse.settings = [{key: 'visibility', value: 'public'}];
|
||||||
|
|
||||||
request.put(localUtils.API.getApiQuery('settings/'))
|
return request.put(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send(jsonResponse)
|
.send(jsonResponse)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(403)
|
.expect(403)
|
||||||
.end(function (err, res) {
|
.then(function ({body, headers}) {
|
||||||
if (err) {
|
jsonResponse = body;
|
||||||
return done(err);
|
should.not.exist(headers['x-cache-invalidate']);
|
||||||
}
|
|
||||||
|
|
||||||
jsonResponse = res.body;
|
|
||||||
should.not.exist(res.headers['x-cache-invalidate']);
|
|
||||||
should.exist(jsonResponse.errors);
|
should.exist(jsonResponse.errors);
|
||||||
testUtils.API.checkResponseValue(jsonResponse.errors[0], [
|
testUtils.API.checkResponseValue(jsonResponse.errors[0], [
|
||||||
'message',
|
'message',
|
||||||
@ -706,8 +659,6 @@ describe('Settings API (v2)', function () {
|
|||||||
'code',
|
'code',
|
||||||
'id'
|
'id'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -322,18 +322,13 @@ describe('Settings API (v3)', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can toggle member setting', function (done) {
|
it('can toggle member setting', function () {
|
||||||
request.get(localUtils.API.getApiQuery('settings/'))
|
return request.get(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.end(function (err, res) {
|
.then(function (res) {
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
const jsonResponse = res.body;
|
const jsonResponse = res.body;
|
||||||
const changedValue = [];
|
|
||||||
|
|
||||||
const settingToChange = {
|
const settingToChange = {
|
||||||
settings: [
|
settings: [
|
||||||
@ -347,25 +342,19 @@ describe('Settings API (v3)', function () {
|
|||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
should.exist(jsonResponse.settings);
|
should.exist(jsonResponse.settings);
|
||||||
|
|
||||||
request.put(localUtils.API.getApiQuery('settings/'))
|
return request.put(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send(settingToChange)
|
.send(settingToChange)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function (err, res) {
|
.then(function ({body, headers}) {
|
||||||
if (err) {
|
const putBody = body;
|
||||||
return done(err);
|
headers['x-cache-invalidate'].should.eql('/*');
|
||||||
}
|
|
||||||
|
|
||||||
const putBody = res.body;
|
|
||||||
res.headers['x-cache-invalidate'].should.eql('/*');
|
|
||||||
should.exist(putBody);
|
should.exist(putBody);
|
||||||
|
|
||||||
putBody.settings[0].key.should.eql('labs');
|
putBody.settings[0].key.should.eql('labs');
|
||||||
putBody.settings[0].value.should.eql(JSON.stringify({subscribers: false, members: false}));
|
putBody.settings[0].value.should.eql(JSON.stringify({subscribers: false, members: false}));
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -390,36 +379,28 @@ describe('Settings API (v3)', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can\'t edit non existent setting', function (done) {
|
it('can\'t edit non existent setting', function () {
|
||||||
request.get(localUtils.API.getApiQuery('settings/'))
|
return request.get(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.end(function (err, res) {
|
.then(function (res) {
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
let jsonResponse = res.body;
|
let jsonResponse = res.body;
|
||||||
const newValue = 'new value';
|
const newValue = 'new value';
|
||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
should.exist(jsonResponse.settings);
|
should.exist(jsonResponse.settings);
|
||||||
jsonResponse.settings = [{key: 'testvalue', value: newValue}];
|
jsonResponse.settings = [{key: 'testvalue', value: newValue}];
|
||||||
|
|
||||||
request.put(localUtils.API.getApiQuery('settings/'))
|
return request.put(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send(jsonResponse)
|
.send(jsonResponse)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(404)
|
.expect(404)
|
||||||
.end(function (err, res) {
|
.then(function ({body, headers}) {
|
||||||
if (err) {
|
jsonResponse = body;
|
||||||
return done(err);
|
should.not.exist(headers['x-cache-invalidate']);
|
||||||
}
|
|
||||||
|
|
||||||
jsonResponse = res.body;
|
|
||||||
should.not.exist(res.headers['x-cache-invalidate']);
|
|
||||||
should.exist(jsonResponse.errors);
|
should.exist(jsonResponse.errors);
|
||||||
testUtils.API.checkResponseValue(jsonResponse.errors[0], [
|
testUtils.API.checkResponseValue(jsonResponse.errors[0], [
|
||||||
'message',
|
'message',
|
||||||
@ -431,21 +412,16 @@ describe('Settings API (v3)', function () {
|
|||||||
'code',
|
'code',
|
||||||
'id'
|
'id'
|
||||||
]);
|
]);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Will transform "1"', function (done) {
|
it('Will transform "1"', function () {
|
||||||
request.get(localUtils.API.getApiQuery('settings/'))
|
return request.get(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.end(function (err, res) {
|
.then(function (res) {
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
const jsonResponse = res.body;
|
const jsonResponse = res.body;
|
||||||
|
|
||||||
const settingToChange = {
|
const settingToChange = {
|
||||||
@ -460,26 +436,21 @@ describe('Settings API (v3)', function () {
|
|||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
should.exist(jsonResponse.settings);
|
should.exist(jsonResponse.settings);
|
||||||
|
|
||||||
request.put(localUtils.API.getApiQuery('settings/'))
|
return request.put(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send(settingToChange)
|
.send(settingToChange)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function (err, res) {
|
.then(function ({body, headers}) {
|
||||||
if (err) {
|
const putBody = body;
|
||||||
return done(err);
|
headers['x-cache-invalidate'].should.eql('/*');
|
||||||
}
|
|
||||||
|
|
||||||
const putBody = res.body;
|
|
||||||
res.headers['x-cache-invalidate'].should.eql('/*');
|
|
||||||
should.exist(putBody);
|
should.exist(putBody);
|
||||||
|
|
||||||
putBody.settings[0].key.should.eql('is_private');
|
putBody.settings[0].key.should.eql('is_private');
|
||||||
putBody.settings[0].value.should.eql(true);
|
putBody.settings[0].value.should.eql(true);
|
||||||
|
|
||||||
localUtils.API.checkResponse(putBody, 'settings');
|
localUtils.API.checkResponse(putBody, 'settings');
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -558,36 +529,27 @@ describe('Settings API (v3)', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not be able to edit settings', function (done) {
|
it('should not be able to edit settings', function () {
|
||||||
request.get(localUtils.API.getApiQuery('settings/'))
|
return request.get(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.end(function (err, res) {
|
.then(function (res) {
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
let jsonResponse = res.body;
|
let jsonResponse = res.body;
|
||||||
const newValue = 'new value';
|
|
||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
should.exist(jsonResponse.settings);
|
should.exist(jsonResponse.settings);
|
||||||
jsonResponse.settings = [{key: 'visibility', value: 'public'}];
|
jsonResponse.settings = [{key: 'visibility', value: 'public'}];
|
||||||
|
|
||||||
request.put(localUtils.API.getApiQuery('settings/'))
|
return request.put(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send(jsonResponse)
|
.send(jsonResponse)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(403)
|
.expect(403)
|
||||||
.end(function (err, res) {
|
.then(function ({body, headers}) {
|
||||||
if (err) {
|
jsonResponse = body;
|
||||||
return done(err);
|
should.not.exist(headers['x-cache-invalidate']);
|
||||||
}
|
|
||||||
|
|
||||||
jsonResponse = res.body;
|
|
||||||
should.not.exist(res.headers['x-cache-invalidate']);
|
|
||||||
should.exist(jsonResponse.errors);
|
should.exist(jsonResponse.errors);
|
||||||
testUtils.API.checkResponseValue(jsonResponse.errors[0], [
|
testUtils.API.checkResponseValue(jsonResponse.errors[0], [
|
||||||
'message',
|
'message',
|
||||||
@ -599,8 +561,6 @@ describe('Settings API (v3)', function () {
|
|||||||
'code',
|
'code',
|
||||||
'id'
|
'id'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -628,36 +588,28 @@ describe('Settings API (v3)', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not be able to edit settings', function (done) {
|
it('should not be able to edit settings', function () {
|
||||||
request.get(localUtils.API.getApiQuery('settings/'))
|
return request.get(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.end(function (err, res) {
|
.then(function (res) {
|
||||||
if (err) {
|
|
||||||
return done(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
let jsonResponse = res.body;
|
let jsonResponse = res.body;
|
||||||
const newValue = 'new value';
|
const newValue = 'new value';
|
||||||
should.exist(jsonResponse);
|
should.exist(jsonResponse);
|
||||||
should.exist(jsonResponse.settings);
|
should.exist(jsonResponse.settings);
|
||||||
jsonResponse.settings = [{key: 'visibility', value: 'public'}];
|
jsonResponse.settings = [{key: 'visibility', value: 'public'}];
|
||||||
|
|
||||||
request.put(localUtils.API.getApiQuery('settings/'))
|
return request.put(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
.send(jsonResponse)
|
.send(jsonResponse)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
.expect(403)
|
.expect(403)
|
||||||
.end(function (err, res) {
|
.then(function ({body, headers}) {
|
||||||
if (err) {
|
jsonResponse = body;
|
||||||
return done(err);
|
should.not.exist(headers['x-cache-invalidate']);
|
||||||
}
|
|
||||||
|
|
||||||
jsonResponse = res.body;
|
|
||||||
should.not.exist(res.headers['x-cache-invalidate']);
|
|
||||||
should.exist(jsonResponse.errors);
|
should.exist(jsonResponse.errors);
|
||||||
testUtils.API.checkResponseValue(jsonResponse.errors[0], [
|
testUtils.API.checkResponseValue(jsonResponse.errors[0], [
|
||||||
'message',
|
'message',
|
||||||
@ -669,8 +621,6 @@ describe('Settings API (v3)', function () {
|
|||||||
'code',
|
'code',
|
||||||
'id'
|
'id'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -39,8 +39,8 @@ describe.skip('Scheduling: Post Scheduling', function () {
|
|||||||
return Promise.resolve({posts: scope.scheduledPosts});
|
return Promise.resolve({posts: scope.scheduledPosts});
|
||||||
});
|
});
|
||||||
|
|
||||||
sinon.stub(events, 'onMany').callsFake(function (events, stubDone) {
|
sinon.stub(events, 'onMany').callsFake(function (stubedEvents, stubDone) {
|
||||||
events.forEach(function (event) {
|
stubedEvents.forEach(function (event) {
|
||||||
scope.events[event] = stubDone;
|
scope.events[event] = stubDone;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -58,12 +58,12 @@ describe('Unit: api/shared/http', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('api response is fn', function (done) {
|
it('api response is fn', function (done) {
|
||||||
const response = sinon.stub().callsFake(function (req, res, next) {
|
const response = sinon.stub().callsFake(function (_req, _res, _next) {
|
||||||
should.exist(req);
|
should.exist(_req);
|
||||||
should.exist(res);
|
should.exist(_res);
|
||||||
should.exist(next);
|
should.exist(_next);
|
||||||
apiImpl.calledOnce.should.be.true();
|
apiImpl.calledOnce.should.be.true();
|
||||||
res.json.called.should.be.false();
|
_res.json.called.should.be.false();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ describe('Unit: api/shared/pipeline', function () {
|
|||||||
shared.pipeline.STAGES.serialisation.input.resolves();
|
shared.pipeline.STAGES.serialisation.input.resolves();
|
||||||
shared.pipeline.STAGES.permissions.resolves();
|
shared.pipeline.STAGES.permissions.resolves();
|
||||||
shared.pipeline.STAGES.query.resolves('response');
|
shared.pipeline.STAGES.query.resolves('response');
|
||||||
shared.pipeline.STAGES.serialisation.output.callsFake(function (response, apiUtils, apiConfig, apiImpl, frame) {
|
shared.pipeline.STAGES.serialisation.output.callsFake(function (response, _apiUtils, apiConfig, apiImpl, frame) {
|
||||||
frame.response = response;
|
frame.response = response;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -62,8 +62,8 @@ describe('{{amp_content}} helper', function () {
|
|||||||
amperizeCache[1].should.have.property('amp', testData.html);
|
amperizeCache[1].should.have.property('amp', testData.html);
|
||||||
// call it again, to make it fetch from cache
|
// call it again, to make it fetch from cache
|
||||||
ampCachedResult = ampContentHelper.call(testData);
|
ampCachedResult = ampContentHelper.call(testData);
|
||||||
ampCachedResult.then(function (rendered) {
|
ampCachedResult.then(function (cachedResult) {
|
||||||
should.exist(rendered);
|
should.exist(cachedResult);
|
||||||
should.exist(amperizeCache);
|
should.exist(amperizeCache);
|
||||||
amperizeCache[1].should.have.property('updated_at', 'Wed Jul 27 2016 18:17:22 GMT+0200 (CEST)');
|
amperizeCache[1].should.have.property('updated_at', 'Wed Jul 27 2016 18:17:22 GMT+0200 (CEST)');
|
||||||
amperizeCache[1].should.have.property('amp', testData.html);
|
amperizeCache[1].should.have.property('amp', testData.html);
|
||||||
@ -97,14 +97,14 @@ describe('{{amp_content}} helper', function () {
|
|||||||
|
|
||||||
// call it again with different values to fetch from Amperize and not from cache
|
// call it again with different values to fetch from Amperize and not from cache
|
||||||
ampResult = ampContentHelper.call(testData2);
|
ampResult = ampContentHelper.call(testData2);
|
||||||
ampResult.then(function (rendered) {
|
ampResult.then(function (cachedResult) {
|
||||||
should.exist(rendered);
|
should.exist(cachedResult);
|
||||||
should.exist(amperizeCache);
|
should.exist(amperizeCache);
|
||||||
|
|
||||||
// it should not have the old value,
|
// it should not have the old value,
|
||||||
amperizeCache[1].should.not.have.property('Wed Jul 30 2016 18:17:22 GMT+0200 (CEST)');
|
amperizeCache[1].should.not.have.property('Wed Jul 30 2016 18:17:22 GMT+0200 (CEST)');
|
||||||
// only the new one
|
// only the new one
|
||||||
rendered.string.should.equal(testData2.html);
|
cachedResult.string.should.equal(testData2.html);
|
||||||
amperizeCache[1].should.have.property('updated_at', 'Wed Jul 30 2016 18:17:22 GMT+0200 (CEST)');
|
amperizeCache[1].should.have.property('updated_at', 'Wed Jul 30 2016 18:17:22 GMT+0200 (CEST)');
|
||||||
amperizeCache[1].should.have.property('amp', testData2.html);
|
amperizeCache[1].should.have.property('amp', testData2.html);
|
||||||
done();
|
done();
|
||||||
|
@ -58,8 +58,8 @@ describe('Unit - apps/amp/lib/router', function () {
|
|||||||
|
|
||||||
describe('fn: renderer', function () {
|
describe('fn: renderer', function () {
|
||||||
it('should render default amp page when theme has no amp template', function (done) {
|
it('should render default amp page when theme has no amp template', function (done) {
|
||||||
helpers.renderer.callsFake(function (req, res, data) {
|
helpers.renderer.callsFake(function (_req, _res, data) {
|
||||||
res.routerOptions.defaultTemplate.should.eql(defaultPath);
|
_res.routerOptions.defaultTemplate.should.eql(defaultPath);
|
||||||
data.should.eql({post: {title: 'test'}});
|
data.should.eql({post: {title: 'test'}});
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -93,8 +93,6 @@ describe('Unit - apps/amp/lib/router', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('fn: getPostData', function () {
|
describe('fn: getPostData', function () {
|
||||||
let res;
|
|
||||||
let req;
|
|
||||||
let entryLookupStub;
|
let entryLookupStub;
|
||||||
let post;
|
let post;
|
||||||
|
|
||||||
|
@ -5,13 +5,12 @@ const urlUtils = require('../../../utils/urlUtils');
|
|||||||
|
|
||||||
describe('getPaginatedUrl', function () {
|
describe('getPaginatedUrl', function () {
|
||||||
let data;
|
let data;
|
||||||
let getTestUrls;
|
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
data = {};
|
data = {};
|
||||||
});
|
});
|
||||||
|
|
||||||
getTestUrls = function getTestUrls() {
|
const getTestUrls = function getTestUrls() {
|
||||||
return {
|
return {
|
||||||
next: getPaginatedUrl('next', data, true),
|
next: getPaginatedUrl('next', data, true),
|
||||||
prev: getPaginatedUrl('prev', data, true),
|
prev: getPaginatedUrl('prev', data, true),
|
||||||
|
@ -31,8 +31,8 @@ describe('{{#foreach}} helper', function () {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
function runTest(self, context, options) {
|
function runTest(self, _context, _options) {
|
||||||
helpers.foreach.call(self, context, options);
|
helpers.foreach.call(self, _context, _options);
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should not populate data if no private data is supplied (array)', function () {
|
it('should not populate data if no private data is supplied (array)', function () {
|
||||||
@ -567,14 +567,14 @@ describe('{{#foreach}} helper', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should output nothing if all tags are internal', function () {
|
it('should output nothing if all tags are internal', function () {
|
||||||
const tagArrayHash = {
|
const internalTagArrayHash = {
|
||||||
tags: [
|
tags: [
|
||||||
{name: 'first', visibility: 'internal'},
|
{name: 'first', visibility: 'internal'},
|
||||||
{name: 'second', visibility: 'internal'}
|
{name: 'second', visibility: 'internal'}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
const tagObjectHash = {
|
const internalTagObjectHash = {
|
||||||
tags: {
|
tags: {
|
||||||
first: {name: 'first', visibility: 'internal'},
|
first: {name: 'first', visibility: 'internal'},
|
||||||
second: {name: 'second', visibility: 'internal'}
|
second: {name: 'second', visibility: 'internal'}
|
||||||
@ -584,8 +584,8 @@ describe('{{#foreach}} helper', function () {
|
|||||||
const templateString = '<ul>{{#foreach tags}}<li>{{@index}} {{name}}</li>{{/foreach}}</ul>';
|
const templateString = '<ul>{{#foreach tags}}<li>{{@index}} {{name}}</li>{{/foreach}}</ul>';
|
||||||
const expected = '<ul></ul>';
|
const expected = '<ul></ul>';
|
||||||
|
|
||||||
shouldCompileToExpected(templateString, tagObjectHash, expected);
|
shouldCompileToExpected(templateString, internalTagObjectHash, expected);
|
||||||
shouldCompileToExpected(templateString, tagArrayHash, expected);
|
shouldCompileToExpected(templateString, internalTagArrayHash, expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -29,10 +29,10 @@ describe('{{#has}} helper', function () {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
function callHasHelper(thisCtx, hash) {
|
function callHasHelper(context, hash) {
|
||||||
// Hash is the options passed in
|
// Hash is the options passed in
|
||||||
handlebarsOptions.hash = hash;
|
handlebarsOptions.hash = hash;
|
||||||
return helpers.has.call(thisCtx, handlebarsOptions);
|
return helpers.has.call(context, handlebarsOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('tag match', function () {
|
describe('tag match', function () {
|
||||||
|
@ -271,8 +271,6 @@ describe('{{url}} helper', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('with subdir', function () {
|
describe('with subdir', function () {
|
||||||
let sandbox;
|
|
||||||
|
|
||||||
before(function () {
|
before(function () {
|
||||||
sandbox = sinon.createSandbox();
|
sandbox = sinon.createSandbox();
|
||||||
urlUtils.stubUrlUtils({url: 'http://localhost:65535/blog'}, sandbox);
|
urlUtils.stubUrlUtils({url: 'http://localhost:65535/blog'}, sandbox);
|
||||||
|
@ -67,8 +67,8 @@ describe('Models: base', function () {
|
|||||||
security.string.safe.withArgs(slug).returns(slug);
|
security.string.safe.withArgs(slug).returns(slug);
|
||||||
|
|
||||||
return models.Base.Model.generateSlug(Model, slug, options)
|
return models.Base.Model.generateSlug(Model, slug, options)
|
||||||
.then((slug) => {
|
.then((generatedSlug) => {
|
||||||
slug.should.eql(new Array(186).join('a'));
|
generatedSlug.should.eql(new Array(186).join('a'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -79,8 +79,8 @@ describe('Models: base', function () {
|
|||||||
security.string.safe.withArgs(slug).returns(slug);
|
security.string.safe.withArgs(slug).returns(slug);
|
||||||
|
|
||||||
return models.Base.Model.generateSlug(Model, slug, options)
|
return models.Base.Model.generateSlug(Model, slug, options)
|
||||||
.then((slug) => {
|
.then((generatedSlug) => {
|
||||||
slug.should.eql('upsi-tableName');
|
generatedSlug.should.eql('upsi-tableName');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -95,8 +95,8 @@ describe('Models: base', function () {
|
|||||||
security.string.safe.withArgs(slug).returns(slug);
|
security.string.safe.withArgs(slug).returns(slug);
|
||||||
|
|
||||||
return models.Base.Model.generateSlug(Model, slug, options)
|
return models.Base.Model.generateSlug(Model, slug, options)
|
||||||
.then((slug) => {
|
.then((generatedSlug) => {
|
||||||
slug.should.eql('hash-#lul');
|
generatedSlug.should.eql('hash-#lul');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ describe('Unit: models/member', function () {
|
|||||||
let toJSON;
|
let toJSON;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
toJSON = function toJSON(model, options) {
|
toJSON = function (model, options) {
|
||||||
return new models.Member(model).toJSON(options);
|
return new models.Member(model).toJSON(options);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -191,8 +191,6 @@ describe('Mail: Ghostmailer', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('should fall back to [blog.title] <noreply@[blog.url]>', function () {
|
describe('should fall back to [blog.title] <noreply@[blog.url]>', function () {
|
||||||
let mailer;
|
|
||||||
|
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
mailer = new mail.GhostMailer();
|
mailer = new mail.GhostMailer();
|
||||||
sandbox.stub(mailer, 'sendMail').resolves();
|
sandbox.stub(mailer, 'sendMail').resolves();
|
||||||
|
@ -78,17 +78,17 @@ describe('Permissions', function () {
|
|||||||
it('can load an actions map from existing permissions', function (done) {
|
it('can load an actions map from existing permissions', function (done) {
|
||||||
fakePermissions = loadFakePermissions();
|
fakePermissions = loadFakePermissions();
|
||||||
|
|
||||||
permissions.init().then(function (actionsMap) {
|
permissions.init().then(function (actions) {
|
||||||
should.exist(actionsMap);
|
should.exist(actions);
|
||||||
|
|
||||||
permissions.canThis.should.not.throwError();
|
permissions.canThis.should.not.throwError();
|
||||||
|
|
||||||
_.keys(actionsMap).should.eql(['browse', 'edit', 'add', 'destroy']);
|
_.keys(actions).should.eql(['browse', 'edit', 'add', 'destroy']);
|
||||||
|
|
||||||
actionsMap.browse.should.eql(['post']);
|
actions.browse.should.eql(['post']);
|
||||||
actionsMap.edit.should.eql(['post', 'tag', 'user', 'page']);
|
actions.edit.should.eql(['post', 'tag', 'user', 'page']);
|
||||||
actionsMap.add.should.eql(['post', 'user', 'page']);
|
actions.add.should.eql(['post', 'user', 'page']);
|
||||||
actionsMap.destroy.should.eql(['post', 'user']);
|
actions.destroy.should.eql(['post', 'user']);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
}).catch(done);
|
}).catch(done);
|
||||||
@ -97,17 +97,17 @@ describe('Permissions', function () {
|
|||||||
it('can load an actions map from existing permissions, and deduplicate', function (done) {
|
it('can load an actions map from existing permissions, and deduplicate', function (done) {
|
||||||
fakePermissions = loadFakePermissions({extra: true});
|
fakePermissions = loadFakePermissions({extra: true});
|
||||||
|
|
||||||
permissions.init().then(function (actionsMap) {
|
permissions.init().then(function (actions) {
|
||||||
should.exist(actionsMap);
|
should.exist(actions);
|
||||||
|
|
||||||
permissions.canThis.should.not.throwError();
|
permissions.canThis.should.not.throwError();
|
||||||
|
|
||||||
_.keys(actionsMap).should.eql(['browse', 'edit', 'add', 'destroy']);
|
_.keys(actions).should.eql(['browse', 'edit', 'add', 'destroy']);
|
||||||
|
|
||||||
actionsMap.browse.should.eql(['post']);
|
actions.browse.should.eql(['post']);
|
||||||
actionsMap.edit.should.eql(['post', 'tag', 'user', 'page']);
|
actions.edit.should.eql(['post', 'tag', 'user', 'page']);
|
||||||
actionsMap.add.should.eql(['post', 'user', 'page']);
|
actions.add.should.eql(['post', 'user', 'page']);
|
||||||
actionsMap.destroy.should.eql(['post', 'user']);
|
actions.destroy.should.eql(['post', 'user']);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
}).catch(done);
|
}).catch(done);
|
||||||
|
@ -122,8 +122,8 @@ describe('Permissions', function () {
|
|||||||
|
|
||||||
return applyPublicRules('posts', 'read', _.cloneDeep(draft)).then(function () {
|
return applyPublicRules('posts', 'read', _.cloneDeep(draft)).then(function () {
|
||||||
done('Did not throw an error for draft');
|
done('Did not throw an error for draft');
|
||||||
}).catch(function (err) {
|
}).catch(function (error) {
|
||||||
(err instanceof errors.NoPermissionError).should.eql(true);
|
(error instanceof errors.NoPermissionError).should.eql(true);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -123,7 +123,7 @@ describe('Unit - services/routing/controllers/entry', function () {
|
|||||||
entry: post
|
entry: post
|
||||||
});
|
});
|
||||||
|
|
||||||
urlUtils.redirectToAdmin.callsFake(function (statusCode, res, editorUrl) {
|
urlUtils.redirectToAdmin.callsFake(function (statusCode, _res, editorUrl) {
|
||||||
statusCode.should.eql(302);
|
statusCode.should.eql(302);
|
||||||
editorUrl.should.eql(EDITOR_URL + post.id);
|
editorUrl.should.eql(EDITOR_URL + post.id);
|
||||||
done();
|
done();
|
||||||
@ -145,7 +145,7 @@ describe('Unit - services/routing/controllers/entry', function () {
|
|||||||
entry: post
|
entry: post
|
||||||
});
|
});
|
||||||
|
|
||||||
urlUtils.redirectToAdmin.callsFake(function (statusCode, res, editorUrl) {
|
urlUtils.redirectToAdmin.callsFake(function (statusCode, _res, editorUrl) {
|
||||||
configUtils.restore();
|
configUtils.restore();
|
||||||
done(new Error('redirectToAdmin was called'));
|
done(new Error('redirectToAdmin was called'));
|
||||||
});
|
});
|
||||||
@ -197,7 +197,7 @@ describe('Unit - services/routing/controllers/entry', function () {
|
|||||||
entry: post
|
entry: post
|
||||||
});
|
});
|
||||||
|
|
||||||
urlUtils.redirect301.callsFake(function (res, postUrl) {
|
urlUtils.redirect301.callsFake(function (_res, postUrl) {
|
||||||
postUrl.should.eql(post.url);
|
postUrl.should.eql(post.url);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -226,7 +226,7 @@ describe('Unit - services/routing/controllers/entry', function () {
|
|||||||
entry: post
|
entry: post
|
||||||
});
|
});
|
||||||
|
|
||||||
urlUtils.redirect301.callsFake(function (res, postUrl) {
|
urlUtils.redirect301.callsFake(function (_res, postUrl) {
|
||||||
postUrl.should.eql(post.url + '?query=true');
|
postUrl.should.eql(post.url + '?query=true');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -65,7 +65,7 @@ describe('Unit - services/routing/controllers/rss', function () {
|
|||||||
posts: posts
|
posts: posts
|
||||||
});
|
});
|
||||||
|
|
||||||
rssService.render.callsFake(function (res, baseUrl, data) {
|
rssService.render.callsFake(function (_res, baseUrl, data) {
|
||||||
baseUrl.should.eql('/rss/');
|
baseUrl.should.eql('/rss/');
|
||||||
data.posts.should.eql(posts);
|
data.posts.should.eql(posts);
|
||||||
data.title.should.eql('Ghost');
|
data.title.should.eql('Ghost');
|
||||||
|
@ -6,7 +6,6 @@ const api = require('../../../../../core/server/api');
|
|||||||
const helpers = require('../../../../../core/frontend/services/routing/helpers');
|
const helpers = require('../../../../../core/frontend/services/routing/helpers');
|
||||||
|
|
||||||
describe('Unit - services/routing/helpers/entry-lookup', function () {
|
describe('Unit - services/routing/helpers/entry-lookup', function () {
|
||||||
let posts;
|
|
||||||
let locals;
|
let locals;
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
|
@ -9,8 +9,8 @@ const middleware = themes.middleware;
|
|||||||
|
|
||||||
const sandbox = sinon.createSandbox();
|
const sandbox = sinon.createSandbox();
|
||||||
|
|
||||||
function executeMiddleware(middleware, req, res, next) {
|
function executeMiddleware(toExecute, req, res, next) {
|
||||||
const [current, ...rest] = middleware;
|
const [current, ...rest] = toExecute;
|
||||||
|
|
||||||
current(req, res, function (err) {
|
current(req, res, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -14,8 +14,8 @@ configUtils.set = function () {
|
|||||||
const value = arguments[1];
|
const value = arguments[1];
|
||||||
|
|
||||||
if (_.isObject(key)) {
|
if (_.isObject(key)) {
|
||||||
_.each(key, function (value, key) {
|
_.each(key, function (settingValue, settingKey) {
|
||||||
config.set(key, value);
|
config.set(settingKey, settingValue);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
config.set(key, value);
|
config.set(key, value);
|
||||||
|
@ -34,20 +34,9 @@ const APIUtils = require('./api');
|
|||||||
const config = require('../../core/shared/config');
|
const config = require('../../core/shared/config');
|
||||||
const knexMigrator = new KnexMigrator();
|
const knexMigrator = new KnexMigrator();
|
||||||
let fixtures;
|
let fixtures;
|
||||||
let getFixtureOps;
|
|
||||||
let toDoList;
|
let toDoList;
|
||||||
let originalRequireFn;
|
let originalRequireFn;
|
||||||
let postsInserted = 0;
|
let postsInserted = 0;
|
||||||
let teardownDb;
|
|
||||||
let setup;
|
|
||||||
let truncate;
|
|
||||||
let createUser;
|
|
||||||
let createPost;
|
|
||||||
let startGhost;
|
|
||||||
let initFixtures;
|
|
||||||
let initData;
|
|
||||||
let clearData;
|
|
||||||
let clearBruteData;
|
|
||||||
|
|
||||||
// Require additional assertions which help us keep our tests small and clear
|
// Require additional assertions which help us keep our tests small and clear
|
||||||
require('./assertions');
|
require('./assertions');
|
||||||
@ -512,7 +501,7 @@ fixtures = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Test Utility Functions **/
|
/** Test Utility Functions **/
|
||||||
initData = function initData() {
|
const initData = function initData() {
|
||||||
return knexMigrator.init()
|
return knexMigrator.init()
|
||||||
.then(function () {
|
.then(function () {
|
||||||
events.emit('db.ready');
|
events.emit('db.ready');
|
||||||
@ -533,11 +522,11 @@ initData = function initData() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
clearBruteData = function clearBruteData() {
|
const clearBruteData = function clearBruteData() {
|
||||||
return db.knex('brute').truncate();
|
return db.knex('brute').truncate();
|
||||||
};
|
};
|
||||||
|
|
||||||
truncate = function truncate(tableName) {
|
const truncate = function truncate(tableName) {
|
||||||
if (config.get('database:client') === 'sqlite3') {
|
if (config.get('database:client') === 'sqlite3') {
|
||||||
return db.knex(tableName).truncate();
|
return db.knex(tableName).truncate();
|
||||||
}
|
}
|
||||||
@ -552,7 +541,7 @@ truncate = function truncate(tableName) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// we must always try to delete all tables
|
// we must always try to delete all tables
|
||||||
clearData = function clearData() {
|
const clearData = function clearData() {
|
||||||
debug('Database reset');
|
debug('Database reset');
|
||||||
return knexMigrator.reset({force: true})
|
return knexMigrator.reset({force: true})
|
||||||
.then(function () {
|
.then(function () {
|
||||||
@ -660,7 +649,7 @@ toDoList = {
|
|||||||
* * `users:roles` - create a full suite of users, one per role
|
* * `users:roles` - create a full suite of users, one per role
|
||||||
* @param {Object} toDos
|
* @param {Object} toDos
|
||||||
*/
|
*/
|
||||||
getFixtureOps = function getFixtureOps(toDos) {
|
const getFixtureOps = function getFixtureOps(toDos) {
|
||||||
// default = default fixtures, if it isn't present, init with tables only
|
// default = default fixtures, if it isn't present, init with tables only
|
||||||
const tablesOnly = !toDos.default;
|
const tablesOnly = !toDos.default;
|
||||||
|
|
||||||
@ -705,7 +694,7 @@ getFixtureOps = function getFixtureOps(toDos) {
|
|||||||
|
|
||||||
// ## Test Setup and Teardown
|
// ## Test Setup and Teardown
|
||||||
|
|
||||||
initFixtures = function initFixtures() {
|
const initFixtures = function initFixtures() {
|
||||||
const options = _.merge({init: true}, _.transform(arguments, function (result, val) {
|
const options = _.merge({init: true}, _.transform(arguments, function (result, val) {
|
||||||
result[val] = true;
|
result[val] = true;
|
||||||
}));
|
}));
|
||||||
@ -721,19 +710,19 @@ initFixtures = function initFixtures() {
|
|||||||
* Setup does 'init' (DB) by default
|
* Setup does 'init' (DB) by default
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
setup = function setup() {
|
const setup = function setup() {
|
||||||
/*eslint no-invalid-this: "off"*/
|
/*eslint no-invalid-this: "off"*/
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
const args = arguments;
|
const args = arguments;
|
||||||
|
|
||||||
return function setup() {
|
return function innerSetup() {
|
||||||
models.init();
|
models.init();
|
||||||
return initFixtures.apply(self, args);
|
return initFixtures.apply(self, args);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
createUser = function createUser(options) {
|
const createUser = function createUser(options) {
|
||||||
const user = options.user;
|
const user = options.user;
|
||||||
const role = options.role;
|
const role = options.role;
|
||||||
|
|
||||||
@ -749,7 +738,7 @@ createUser = function createUser(options) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
createPost = function createPost(options) {
|
const createPost = function createPost(options) {
|
||||||
const post = DataGenerator.forKnex.createPost(options.post);
|
const post = DataGenerator.forKnex.createPost(options.post);
|
||||||
|
|
||||||
if (options.author) {
|
if (options.author) {
|
||||||
@ -764,7 +753,7 @@ createPost = function createPost(options) {
|
|||||||
* Has to run in a transaction for MySQL, otherwise the foreign key check does not work.
|
* Has to run in a transaction for MySQL, otherwise the foreign key check does not work.
|
||||||
* Sqlite3 has no truncate command.
|
* Sqlite3 has no truncate command.
|
||||||
*/
|
*/
|
||||||
teardownDb = function teardownDb() {
|
const teardownDb = function teardownDb() {
|
||||||
debug('Database teardown');
|
debug('Database teardown');
|
||||||
urlService.softReset();
|
urlService.softReset();
|
||||||
|
|
||||||
@ -815,7 +804,7 @@ let ghostServer;
|
|||||||
*
|
*
|
||||||
* @TODO: tidy up the tmp folders
|
* @TODO: tidy up the tmp folders
|
||||||
*/
|
*/
|
||||||
startGhost = function startGhost(options) {
|
const startGhost = function startGhost(options) {
|
||||||
console.time('Start Ghost'); // eslint-disable-line no-console
|
console.time('Start Ghost'); // eslint-disable-line no-console
|
||||||
options = _.merge({
|
options = _.merge({
|
||||||
redirectsFile: true,
|
redirectsFile: true,
|
||||||
@ -948,7 +937,7 @@ startGhost = function startGhost(options) {
|
|||||||
|
|
||||||
return ghost();
|
return ghost();
|
||||||
})
|
})
|
||||||
.then(function startGhost(_ghostServer) {
|
.then(function startGhostServer(_ghostServer) {
|
||||||
ghostServer = _ghostServer;
|
ghostServer = _ghostServer;
|
||||||
|
|
||||||
if (options.subdir) {
|
if (options.subdir) {
|
||||||
@ -1020,9 +1009,9 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
integrationTesting: {
|
integrationTesting: {
|
||||||
overrideGhostConfig: function overrideGhostConfig(configUtils) {
|
overrideGhostConfig: function overrideGhostConfig(utils) {
|
||||||
configUtils.set('paths:contentPath', path.join(__dirname, 'fixtures'));
|
utils.set('paths:contentPath', path.join(__dirname, 'fixtures'));
|
||||||
configUtils.set('times:getImageSizeTimeoutInMS', 1);
|
utils.set('times:getImageSizeTimeoutInMS', 1);
|
||||||
},
|
},
|
||||||
|
|
||||||
defaultMocks: function defaultMocks(sandbox, options) {
|
defaultMocks: function defaultMocks(sandbox, options) {
|
||||||
|
Loading…
Reference in New Issue
Block a user