mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-12 16:14:25 +03:00
commit
d386f66f1e
@ -18,6 +18,15 @@ utils = {
|
||||
if (_.isEmpty(object) || _.isEmpty(object[docName]) || _.isEmpty(object[docName][0])) {
|
||||
return when.reject(new errors.BadRequestError('No root key (\'' + docName + '\') provided.'));
|
||||
}
|
||||
|
||||
// convert author property to author_id to match the name in the database
|
||||
// TODO: rename object in database
|
||||
if (docName === 'posts') {
|
||||
if (object.posts[0].hasOwnProperty('author')) {
|
||||
object.posts[0].author_id = object.posts[0].author;
|
||||
delete object.posts[0].author;
|
||||
}
|
||||
}
|
||||
return when.resolve(object);
|
||||
}
|
||||
};
|
||||
|
@ -438,9 +438,11 @@ describe('Post API', function () {
|
||||
}
|
||||
|
||||
var jsonResponse = res.body,
|
||||
changedValue = 'My new Title';
|
||||
changedTitle = 'My new Title',
|
||||
changedAuthor = 2;
|
||||
jsonResponse.posts[0].should.exist;
|
||||
jsonResponse.posts[0].title = changedValue;
|
||||
jsonResponse.posts[0].title = changedTitle;
|
||||
jsonResponse.posts[0].author = changedAuthor;
|
||||
|
||||
request.put(testUtils.API.getApiQuery('posts/1/'))
|
||||
.set('Authorization', 'Bearer ' + accesstoken)
|
||||
@ -455,7 +457,8 @@ describe('Post API', function () {
|
||||
var putBody = res.body;
|
||||
_.has(res.headers, 'x-cache-invalidate').should.equal(true);
|
||||
putBody.should.exist;
|
||||
putBody.posts[0].title.should.eql(changedValue);
|
||||
putBody.posts[0].title.should.eql(changedTitle);
|
||||
putBody.posts[0].author.should.eql(changedAuthor);
|
||||
|
||||
testUtils.API.checkResponse(putBody.posts[0], 'post');
|
||||
done();
|
||||
|
Loading…
Reference in New Issue
Block a user