2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

Moved toJSON call to api v0.1 controller for ownership transfer

refs #9866
This commit is contained in:
kirrg001 2018-10-12 18:12:16 +02:00
parent 0a834d4223
commit 551f14d9ec
3 changed files with 3 additions and 8 deletions

View file

@ -330,11 +330,9 @@ users = {
*/ */
function doQuery(options) { function doQuery(options) {
return models.User.transferOwnership(options.data.owner[0], _.omit(options, ['data'])) return models.User.transferOwnership(options.data.owner[0], _.omit(options, ['data']))
.then((model) => { .then((models) => {
// NOTE: model returns json object already
// @TODO: why?
return { return {
users: model users: models.toJSON(_.omit(options, ['data']))
}; };
}); });
} }

View file

@ -899,10 +899,6 @@ User = ghostBookshelf.Model.extend({
return Users.forge() return Users.forge()
.query('whereIn', 'id', [contextUser.id, results[2]]) .query('whereIn', 'id', [contextUser.id, results[2]])
.fetch({withRelated: ['roles']}); .fetch({withRelated: ['roles']});
})
.then(function then(users) {
options.withRelated = ['roles'];
return users.toJSON(options);
}); });
}, },

View file

@ -461,6 +461,7 @@ describe('User API', function () {
.expect('Cache-Control', testUtils.cacheRules.private) .expect('Cache-Control', testUtils.cacheRules.private)
.expect(200) .expect(200)
.then((res) => { .then((res) => {
res.body.users.length.should.eql(2);
res.body.users[0].roles[0].name.should.equal(testUtils.DataGenerator.Content.roles[0].name); res.body.users[0].roles[0].name.should.equal(testUtils.DataGenerator.Content.roles[0].name);
res.body.users[1].roles[0].name.should.equal(testUtils.DataGenerator.Content.roles[3].name); res.body.users[1].roles[0].name.should.equal(testUtils.DataGenerator.Content.roles[3].name);
}); });