Merge pull request #6714 from kevinansfield/allow-mocked-endpoints-in-dev

Enable ability to mock endpoints in development mode
This commit is contained in:
Hannah Wolfe 2016-04-14 19:12:43 +01:00
commit 999f7d43e2
2 changed files with 17 additions and 7 deletions

View File

@ -52,6 +52,22 @@ export default function () {
this.namespace = 'ghost/api/v0.1'; // make this `api`, for example, if your API is namespaced
// this.timing = 400; // delay for each request, automatically set to 0 during testing
// Mock endpoints here to override real API requests during development
// keep this line, it allows all other API requests to hit the real server
this.passthrough();
// add any external domains to make sure those get passed through too
this.passthrough('https://count.ghost.org/');
this.passthrough('http://www.gravatar.com/**');
}
// Mock all endpoints here as there is no real API during testing
export function testConfig() {
// this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server
this.namespace = 'ghost/api/v0.1'; // make this `api`, for example, if your API is namespaced
// this.timing = 400; // delay for each request, automatically set to 0 during testing
/* Authentication ------------------------------------------------------- */
this.post('/authentication/token', function () {
@ -326,10 +342,3 @@ export default function () {
};
});
}
/*
You can optionally export a config that is only loaded during tests
export function testConfig() {
}
*/

View File

@ -32,6 +32,7 @@ module.exports = function (environment) {
ENV.APP.LOG_TRANSITIONS = true;
ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
ENV.APP.LOG_VIEW_LOOKUPS = true;
// Enable mirage here in order to mock API endpoints during development
ENV['ember-cli-mirage'] = {
enabled: false
};