🐛 Allowed data in collections to use specified key (#10559)

closes #10434

This adds the list of objects to the specified key,
finishing off the work started in the PR here:
https://github.com/TryGhost/Ghost/pull/10449
This commit is contained in:
Fabien O'Carroll 2019-03-04 17:53:58 +01:00 committed by GitHub
parent f846bd8033
commit 98b4940f70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -105,10 +105,12 @@ function fetchData(pathOptions, routerOptions, locals) {
response.data = {};
_.each(routerOptions.data, function (config, name) {
response.data[name] = results[name][config.resource];
if (config.type === 'browse') {
response.data[name] = results[name];
} else {
response.data[name] = results[name][config.resource];
response.data[name].meta = results[name].meta;
// @TODO remove in v3
response.data[name][config.resource] = results[name][config.resource];
}
});
}

View File

@ -98,6 +98,8 @@ describe('Unit - services/routing/helpers/fetch-data', function () {
result.data.featured.should.not.have.properties('data');
result.posts.length.should.eql(posts.length);
result.data.featured.length.should.eql(posts.length);
// @TODO v3 will deprecate this style (featured.posts)
result.data.featured.posts.length.should.eql(posts.length);
api.posts.browse.calledTwice.should.be.true();
@ -133,6 +135,8 @@ describe('Unit - services/routing/helpers/fetch-data', function () {
result.data.featured.should.not.have.properties('data');
result.posts.length.should.eql(posts.length);
result.data.featured.length.should.eql(posts.length);
// @TODO v3 will deprecate this style (featured.posts)
result.data.featured.posts.length.should.eql(posts.length);
api.posts.browse.calledTwice.should.be.true();