2016-06-03 13:51:06 +03:00
|
|
|
import { expect } from 'chai';
|
|
|
|
import {
|
|
|
|
describeModule,
|
|
|
|
it
|
|
|
|
} from 'ember-mocha';
|
|
|
|
import Pretender from 'pretender';
|
2016-05-24 15:06:59 +03:00
|
|
|
import config from 'ghost-admin/config/environment';
|
2016-06-03 13:51:06 +03:00
|
|
|
|
|
|
|
describeModule(
|
|
|
|
'service:store',
|
|
|
|
'Integration: Service: store',
|
|
|
|
{
|
|
|
|
integration: true
|
|
|
|
},
|
|
|
|
function () {
|
|
|
|
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.subject();
|
|
|
|
|
|
|
|
server.get('/ghost/api/v0.1/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();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|