mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
27dadcf1c4
refs https://github.com/TryGhost/Team/issues/221 - we're getting ready for the 4.0 API version so we should be using canary to fully test the changes - changed from `v3` to `canary` in `utils/ghost-paths.js` - updated mirage and tests to use `ghostPaths` util so we only need to change the version in one place in the future
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
import Pretender from 'pretender';
|
|
import config from 'ghost-admin/config/environment';
|
|
import ghostPaths from 'ghost-admin/utils/ghost-paths';
|
|
import {describe, it} from 'mocha';
|
|
import {expect} from 'chai';
|
|
import {setupTest} from 'ember-mocha';
|
|
|
|
describe('Integration: Service: store', function () {
|
|
setupTest();
|
|
|
|
let server;
|
|
|
|
beforeEach(function () {
|
|
server = new Pretender();
|
|
});
|
|
|
|
afterEach(function () {
|
|
server.shutdown();
|
|
});
|
|
|
|
it('adds Ghost version header to requests', function (done) {
|
|
let {version} = config.APP;
|
|
let store = this.owner.lookup('service:store');
|
|
|
|
server.get(`${ghostPaths().apiRoot}/posts/1/`, function () {
|
|
return [
|
|
404,
|
|
{'Content-Type': 'application/json'},
|
|
JSON.stringify({})
|
|
];
|
|
});
|
|
|
|
store.find('post', 1).catch(() => {
|
|
let [request] = server.handledRequests;
|
|
expect(request.requestHeaders['X-Ghost-Version']).to.equal(version);
|
|
done();
|
|
});
|
|
});
|
|
});
|