mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 05:50: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: {
|
||||
input(apiUtils, apiConfig, apiImpl, frame) {
|
||||
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) {
|
||||
debug('stages: output serialisation');
|
||||
|
@ -27,10 +27,10 @@ describe('Unit: api/shared/serializers/handle', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('ensure serializers are called', function () {
|
||||
const getStub = sandbox.stub();
|
||||
it('ensure serializers are called with apiConfig and frame', function () {
|
||||
const allStub = 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);
|
||||
|
||||
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(() => {
|
||||
getStub.calledOnce.should.be.true();
|
||||
addStub.calledOnce.should.be.true();
|
||||
apiSerializers.all.calledOnce.should.be.true();
|
||||
apiSerializers.posts.all.calledOnce.should.be.true();
|
||||
apiSerializers.posts.add.calledOnce.should.be.true();
|
||||
stubsToCheck.forEach((stub) => {
|
||||
stub.calledOnce.should.be.true();
|
||||
should.equal(stub.args[0][0], apiConfig);
|
||||
should.equal(stub.args[0][1], frame);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user