mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
Added apiImpl.data to apiOptions for serialisation (#10016)
no-issue This is to give serializers access to the expected data properties so that can be used for filtering.
This commit is contained in:
parent
51dde1e38c
commit
2fbc5aa257
@ -32,7 +32,11 @@ const STAGES = {
|
|||||||
serialisation: {
|
serialisation: {
|
||||||
input(apiUtils, apiConfig, apiImpl, frame) {
|
input(apiUtils, apiConfig, apiImpl, frame) {
|
||||||
debug('stages: input serialisation');
|
debug('stages: input serialisation');
|
||||||
return shared.serializers.handle.input(apiConfig, apiUtils.serializers.input, frame);
|
return shared.serializers.handle.input(
|
||||||
|
Object.assign({data: apiImpl.data}, apiConfig),
|
||||||
|
apiUtils.serializers.input,
|
||||||
|
frame
|
||||||
|
);
|
||||||
},
|
},
|
||||||
output(response, apiUtils, apiConfig, apiImpl, frame) {
|
output(response, apiUtils, apiConfig, apiImpl, frame) {
|
||||||
debug('stages: output serialisation');
|
debug('stages: output serialisation');
|
||||||
|
@ -27,10 +27,10 @@ describe('Unit: api/shared/serializers/handle', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('ensure serializers are called', function () {
|
it('ensure serializers are called with apiConfig and frame', function () {
|
||||||
const getStub = sandbox.stub();
|
const allStub = sandbox.stub();
|
||||||
const addStub = sandbox.stub();
|
const addStub = sandbox.stub();
|
||||||
sandbox.stub(shared.serializers.input.all, 'all').get(() => getStub);
|
sandbox.stub(shared.serializers.input.all, 'all').get(() => allStub);
|
||||||
sandbox.stub(shared.serializers.input.all, 'add').get(() => addStub);
|
sandbox.stub(shared.serializers.input.all, 'add').get(() => addStub);
|
||||||
|
|
||||||
const apiSerializers = {
|
const apiSerializers = {
|
||||||
@ -41,13 +41,24 @@ describe('Unit: api/shared/serializers/handle', function () {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return shared.serializers.handle.input({docName: 'posts', method: 'add'}, apiSerializers, {})
|
const apiConfig = {docName: 'posts', method: 'add'};
|
||||||
|
const frame = {};
|
||||||
|
|
||||||
|
const stubsToCheck = [
|
||||||
|
allStub,
|
||||||
|
addStub,
|
||||||
|
apiSerializers.all,
|
||||||
|
apiSerializers.posts.all,
|
||||||
|
apiSerializers.posts.add
|
||||||
|
];
|
||||||
|
|
||||||
|
return shared.serializers.handle.input(apiConfig, apiSerializers, frame)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
getStub.calledOnce.should.be.true();
|
stubsToCheck.forEach((stub) => {
|
||||||
addStub.calledOnce.should.be.true();
|
stub.calledOnce.should.be.true();
|
||||||
apiSerializers.all.calledOnce.should.be.true();
|
should.equal(stub.args[0][0], apiConfig);
|
||||||
apiSerializers.posts.all.calledOnce.should.be.true();
|
should.equal(stub.args[0][1], frame);
|
||||||
apiSerializers.posts.add.calledOnce.should.be.true();
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user