Revert to using findAll for internal tools
refs #5909, #4577 - removes accidental '.only' which was hiding issues with the findAll changes - deleteAllContent and importer still need to use a hard 'findAll' as findPage({limit: 'all'}) doesn't have the same behaviour
This commit is contained in:
parent
4c1828c027
commit
0764c775a7
@ -23,13 +23,13 @@ DataImporter.prototype.loadRoles = function () {
|
||||
|
||||
DataImporter.prototype.loadUsers = function () {
|
||||
var users = {all: {}},
|
||||
options = _.extend({}, {include: ['roles'], limit: 'all'}, internal);
|
||||
options = _.extend({}, {include: ['roles']}, internal);
|
||||
|
||||
return models.User.findPage(options).then(function (data) {
|
||||
data.users.forEach(function (user) {
|
||||
users.all[user.email] = {realId: user.id};
|
||||
if (user.roles[0] && user.roles[0].name === 'Owner') {
|
||||
users.owner = user;
|
||||
return models.User.findAll(options).then(function (_users) {
|
||||
_users.forEach(function (user) {
|
||||
users.all[user.get('email')] = {realId: user.get('id')};
|
||||
if (user.related('roles').toJSON(options)[0] && user.related('roles').toJSON(options)[0].name === 'Owner') {
|
||||
users.owner = user.toJSON(options);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -187,7 +187,7 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({
|
||||
/**
|
||||
* Returns an array of keys permitted in every method's `options` hash.
|
||||
* Can be overridden and added to by a model's `permittedOptions` method.
|
||||
* @return {Array} Keys allowed in the `options` hash of every model's method.
|
||||
* @return {Object} Keys allowed in the `options` hash of every model's method.
|
||||
*/
|
||||
permittedOptions: function permittedOptions() {
|
||||
// terms to whitelist for all methods.
|
||||
@ -229,6 +229,7 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({
|
||||
*/
|
||||
findAll: function findAll(options) {
|
||||
options = this.filterOptions(options, 'findAll');
|
||||
options.withRelated = _.union(options.withRelated, options.include);
|
||||
return this.forge().fetchAll(options).then(function then(result) {
|
||||
if (options.include) {
|
||||
_.each(result.models, function each(item) {
|
||||
|
@ -44,13 +44,13 @@ models = {
|
||||
deleteAllContent: function deleteAllContent() {
|
||||
var self = this;
|
||||
|
||||
return self.Post.findPage({limit: 'all'}).then(function then(data) {
|
||||
return Promise.all(_.map(data.posts, function mapper(post) {
|
||||
return self.Post.findAll().then(function then(posts) {
|
||||
return Promise.all(_.map(posts.toJSON(), function mapper(post) {
|
||||
return self.Post.destroy({id: post.id});
|
||||
}));
|
||||
}).then(function () {
|
||||
return self.Tag.findPage({limit: 'all'}).then(function then(data) {
|
||||
return Promise.all(_.map(data.tags, function mapper(tag) {
|
||||
return self.Tag.findAll().then(function then(tags) {
|
||||
return Promise.all(_.map(tags.toJSON(), function mapper(tag) {
|
||||
return self.Tag.destroy({id: tag.id});
|
||||
}));
|
||||
});
|
||||
|
@ -513,7 +513,7 @@ describe('Post Model', function () {
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
it.only('can save a draft without setting published_by or published_at', function (done) {
|
||||
it('can save a draft without setting published_by or published_at', function (done) {
|
||||
var newPost = testUtils.DataGenerator.forModel.posts[2],
|
||||
postId;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user