Skip to content

Commit

Permalink
🎨 delete all content: do not delete subscribers (#8282)
Browse files Browse the repository at this point in the history
closes #7875
  • Loading branch information
kirrg001 authored and ErisDS committed Apr 5, 2017
1 parent 1b5ac28 commit 1bcd25f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 1 addition & 2 deletions core/server/api/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down
16 changes: 10 additions & 6 deletions core/test/integration/api/api_db_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
});
});
});

Expand All @@ -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);
});
Expand Down

0 comments on commit 1bcd25f

Please sign in to comment.