🎨 delete all content: do not delete subscribers (#8282)

closes #7875
This commit is contained in:
Katharina Irrgang 2017-04-05 22:57:41 +02:00 committed by Hannah Wolfe
parent 1b5ac28faf
commit 1bcd25fdbf
2 changed files with 11 additions and 8 deletions

View File

@ -86,13 +86,12 @@ db = {
function deleteContent() {
var collections = [
models.Subscriber.findAll(queryOpts),
models.Post.findAll(queryOpts),
models.Tag.findAll(queryOpts)
];
return Promise.each(collections, function then(Collection) {
return Collection.invokeThen('destroy');
return Collection.invokeThen('destroy', queryOpts);
}).return({db: []})
.catch(function (err) {
throw new errors.GhostError({err: err});

View File

@ -2,8 +2,7 @@ var should = require('should'),
testUtils = require('../../utils'),
_ = require('lodash'),
dbAPI = require('../../../server/api/db'),
ModelTag = require('../../../server/models/tag'),
ModelPost = require('../../../server/models/post');
models = require('../../../server/models');
describe('DB API', function () {
// Keep the DB clean
@ -19,15 +18,20 @@ describe('DB API', function () {
result.db.should.be.instanceof(Array);
result.db.should.be.empty();
}).then(function () {
return ModelTag.Tag.findAll(testUtils.context.owner).then(function (results) {
return models.Tag.findAll(testUtils.context.owner).then(function (results) {
should.exist(results);
results.length.should.equal(0);
});
}).then(function () {
return ModelPost.Post.findAll(testUtils.context.owner).then(function (results) {
return models.Post.findAll(testUtils.context.owner).then(function (results) {
should.exist(results);
results.length.should.equal(0);
});
}).then(function () {
return models.Subscriber.findAll(testUtils.context.owner).then(function (results) {
should.exist(results);
results.length.should.equal(1);
});
});
});
@ -37,12 +41,12 @@ describe('DB API', function () {
result.db.should.be.instanceof(Array);
result.db.should.be.empty();
}).then(function () {
return ModelTag.Tag.findAll(testUtils.context.admin).then(function (results) {
return models.Tag.findAll(testUtils.context.admin).then(function (results) {
should.exist(results);
results.length.should.equal(0);
});
}).then(function () {
return ModelPost.Post.findAll(testUtils.context.admin).then(function (results) {
return models.Post.findAll(testUtils.context.admin).then(function (results) {
should.exist(results);
results.length.should.equal(0);
});