0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Merge pull request #2497 from sebgie/issue#2492

Fix delete button
This commit is contained in:
Hannah Wolfe 2014-03-24 18:47:25 +00:00
commit 1fbe4d0be7
2 changed files with 62 additions and 8 deletions

View file

@ -1,5 +1,6 @@
var migrations = require('../data/migration'),
_ = require('lodash');
_ = require('lodash'),
when = require('when');
module.exports = {
Post: require('./post').Post,
@ -20,14 +21,14 @@ module.exports = {
var self = this;
return self.Post.browse().then(function (posts) {
_.each(posts.toJSON(), function (post) {
self.Post.destroy(post.id);
});
return when.all(_.map(posts.toJSON(), function (post) {
return self.Post.destroy(post.id);
}));
}).then(function () {
self.Tag.browse().then(function (tags) {
_.each(tags.toJSON(), function (tag) {
self.Tag.destroy(tag.id);
});
return self.Tag.browse().then(function (tags) {
return when.all(_.map(tags.toJSON(), function (tag) {
return self.Tag.destroy(tag.id);
}));
});
});
}

View file

@ -0,0 +1,53 @@
/*globals describe, before, beforeEach, afterEach, it */
var testUtils = require('../../utils'),
should = require('should'),
// Stuff we are testing
DataGenerator = require('../../utils/fixtures/data-generator'),
dbAPI = require('../../../server/api/db');
TagsAPI = require('../../../server/api/tags');
PostAPI = require('../../../server/api/posts');
describe('DB API', function () {
before(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
});
beforeEach(function (done) {
testUtils.initData()
.then(function () {
return testUtils.insertDefaultFixtures();
})
.then(function () {
done();
}, done);
});
afterEach(function (done) {
testUtils.clearData().then(function () {
done();
}, done);
});
it('delete all content', function (done) {
dbAPI.deleteAllContent().then(function (result){
should.exist(result.message);
result.message.should.equal('Successfully deleted all content from your blog.')
}).then(function () {
TagsAPI.browse().then(function (results) {
should.exist(results);
results.length.should.equal(0);
});
}).then(function () {
PostAPI.browse().then(function (results) {
should.exist(results);
results.posts.length.should.equal(0);
done();
});
}).then(null, done);
});
});